From f130c7d877a14a44dfa3060d510b8ec41eea2771 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 28 Dec 2014 20:16:09 -0500 Subject: [PATCH] - merge the safari-related changes to init.js from zzzeeksphinx (cherry picked from commit a2fc048775e3a9104db20881fa333bd7695d24ff) --- doc/build/static/init.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/doc/build/static/init.js b/doc/build/static/init.js index 4bcb4411da..70c6f46161 100644 --- a/doc/build/static/init.js +++ b/doc/build/static/init.js @@ -13,21 +13,36 @@ 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 $("#fixed-sidebar.withsidebar").addClass("preautomated"); - - function setScroll() { - + function setScroll(event) { var scrolltop = $(window).scrollTop(); - if (scrolltop >= automatedBreakpoint) { + if (scrolltop < 0) { + // safari does this + $("#fixed-sidebar.withsidebar").css( + "top", $("#docs-body").offset().top - scrolltop); + } + else if (scrolltop >= automatedBreakpoint) { $("#fixed-sidebar.withsidebar").css("top", 5); } else { - $("#fixed-sidebar.withsidebar").css( + $("#fixed-sidebar.withsidebar").css( "top", $("#docs-body").offset().top - Math.max(scrolltop, 0)); } - + var scrollside = $(window).scrollLeft(); + // more safari crap, side scrolling + $("#fixed-sidebar.withsidebar").css("left", left - scrollside); } $(window).scroll(setScroll) -- 2.47.2