From: Mike Bayer Date: Mon, 29 Dec 2014 01:16:09 +0000 (-0500) Subject: - merge the safari-related changes to init.js from zzzeeksphinx X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2fc048775e3a9104db20881fa333bd7695d24ff;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - merge the safari-related changes to init.js from zzzeeksphinx --- 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)