]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- backport the latest version of scrolling
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Dec 2014 15:35:40 +0000 (10:35 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Dec 2014 15:35:40 +0000 (10:35 -0500)
doc/build/static/init.js

index 70c6f46161d741721dce7fa2bbf353c01b23a8da..cb330bdc928aabd429f41f194b8b29368c33322c 100644 (file)
@@ -7,45 +7,58 @@ function initSQLPopups() {
     });
 }
 
-var automatedBreakpoint = -1;
-
 function initFloatyThings() {
 
-    automatedBreakpoint = $("#docs-container").position().top + $("#docs-top-navigation-container").height();
-
-    left = $("#fixed-sidebar.withsidebar").offset()
-    if (left) {
-        left = left.left;
-    } // otherwise might be undefined
-
     // we use a "fixed" positioning for the sidebar regardless
     // of whether or not we are moving with the page or not because
     // we want it to have an independently-moving scrollbar at all
-    // times.  Otherwise, keeping it with plain positioning before the
-    // page has scrolled works more smoothly on safari, IE
+    // times.
+    // this unfortunately means we either have to keep it steady across
+    // page scrolls or deal with the fact that the text is flowing
+    // under it in some resize/side-scroll scenarios.
+
+    var automatedBreakpoint = $("#docs-container").position().top +
+        $("#docs-top-navigation-container").height();
+
+    var docsBodyOffset = $("#docs-body").offset().top;
+
+    // this turns on the whole thing, without this
+    // we are in graceful degradation assuming no JS
     $("#fixed-sidebar.withsidebar").addClass("preautomated");
 
-    function setScroll(event) {
+    function setScroll() {
         var scrolltop = $(window).scrollTop();
-        if (scrolltop < 0) {
-            // safari does this
-            $("#fixed-sidebar.withsidebar").css(
-                "top", $("#docs-body").offset().top - scrolltop);
-        }
-        else if (scrolltop >= automatedBreakpoint) {
+        var fix = scrolltop >= automatedBreakpoint;
+
+        // when page is scrolled down past the top headers,
+        // sidebar stays fixed vertically
+        if (fix) {
             $("#fixed-sidebar.withsidebar").css("top", 5);
         }
+        else if (scrolltop < 0) {
+            // special trickery to deal with safari vs. chrome
+            // acting differently in this case, while avoiding using jquery's
+            // weird / slow? offset() setter
+            if ($("#fixed-sidebar.withsidebar").offset().top != docsBodyOffset) {
+                $("#fixed-sidebar.withsidebar").css(
+                    "top", docsBodyOffset - scrolltop);
+            }
+        }
         else {
-          $("#fixed-sidebar.withsidebar").css(
-                "top", $("#docs-body").offset().top - Math.max(scrolltop, 0));
+            $("#fixed-sidebar.withsidebar").css(
+                "top", docsBodyOffset - scrolltop);
         }
 
-        var scrollside = $(window).scrollLeft();
-        // more safari crap, side scrolling
-        $("#fixed-sidebar.withsidebar").css("left", left - scrollside);
+        // adjusting left scroll is also an option,
+        // but doesn't seem to be worth it, safari is the only browser
+        // that shows much of a change, and overall the adjustment here
+        // is jerky and error-prone esp. on lesser browsers like safari ipad.
+        // looking at our "mentor" documentation, they don't do this;
+        // they just have the whole layout such that you don't really notice
+        // the horizontal squeezing as much (nav is on the right, they don't
+        // have a border around the text making it obvious).
     }
-    $(window).scroll(setScroll)
-
+    $(window).scroll(setScroll);
     setScroll();
 }