Commits

Tatham Oddie committed 00442de

Add logic to hide address bar on iPhone

  • Participants
  • Parent commits b749df7

Comments (0)

Files changed (1)

Web/Views/Timeline/Index.cshtml

         .on('gesturestart', function (e) {
             e.preventDefault();
         });
+
+    // http://24ways.org/2011/raising-the-bar-on-mobile
+    (function (win) {
+        var doc = win.document;
+        // If there's a hash, or addEventListener is undefined, stop here
+        if (!location.hash && win.addEventListener) {
+            //scroll to 1
+            window.scrollTo(0, 1);
+            var scrollTop = 1,
+            getScrollTop = function () {
+                return win.pageYOffset || doc.compatMode === "CSS1Compat" && doc.documentElement.scrollTop || doc.body.scrollTop || 0;
+            },
+            //reset to 0 on bodyready, if needed
+            bodycheck = setInterval(function () {
+                if (doc.body) {
+                    clearInterval(bodycheck);
+                    scrollTop = getScrollTop();
+                    win.scrollTo(0, scrollTop === 1 ? 0 : 1);
+                }
+            }, 15);
+            win.addEventListener("load", function () {
+                setTimeout(function () {
+                    //reset to hide addr bar at onload
+                    win.scrollTo(0, scrollTop === 1 ? 0 : 1);
+                }, 0);
+            });
+        }
+    })(this);
 </script>