From 4868e9bf92fb88a94c377dfda5d97e38b0948b7d Mon Sep 17 00:00:00 2001 From: Scott Main Date: Mon, 14 Apr 2014 19:00:12 -0700 Subject: [PATCH] remove the animated scroll adjustment for sticky nav. Instead adjust the scroll position based on changes to the hashtag. Change-Id: I34a6b386fa2104f8f2ac04e1d9820199f0ef0e94 --- .../templates-sdk-dyn/assets/js/docs.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tools/droiddoc/templates-sdk-dyn/assets/js/docs.js b/tools/droiddoc/templates-sdk-dyn/assets/js/docs.js index 00a1b2b85f..cfecf30bbb 100644 --- a/tools/droiddoc/templates-sdk-dyn/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk-dyn/assets/js/docs.js @@ -891,9 +891,6 @@ var stickyTop; var hiding = false; var $stickyEl = $('#sticky-header'); var $menuEl = $('.menu-container'); - //var scrollThrottle = -1; - var lastScroll = 0; - var autoScrolling = false; var prevScrollLeft = 0; // used to compare current position to previous position of horiz scroll @@ -951,14 +948,6 @@ var stickyTop; $stickyEl.fadeIn(10); $menuEl.addClass('sticky-menu'); - - // If its a jump then make sure to modify the scroll because of the - // sticky nav - if (!autoScrolling && Math.abs(top - lastScroll > 100)) { - autoScrolling = true; - $('body,html').animate({scrollTop:(top = top - 60)}, '250', 'swing', function() { autoScrolling = false; }); - } - // make the sidenav fixed var width = $('#devdoc-nav').width(); $('#devdoc-nav') @@ -975,7 +964,6 @@ var stickyTop; hiding = false; } - lastScroll = top; resizeNav(250); // pass true in order to delay the scrollbar re-initialization for performance }); @@ -1810,7 +1798,7 @@ function search_changed(e, kd, toroot) $('.suggest-card').hide(); if ($("#searchResults").is(":hidden") && (search.value != "")) { // if results aren't showing (and text not empty), return true to allow search to execute - $('body,html').animate({scrollTop:0}, '500', 'swing', function() { autoScrolling = false; }); + $('body,html').animate({scrollTop:0}, '500', 'swing'); return true; } else { // otherwise, results are already showing, so allow ajax to auto refresh the results @@ -2496,12 +2484,15 @@ google.setOnLoadCallback(function(){ // when an event on the browser history occurs (back, forward, load) requery hash and do search $(window).hashchange( function(){ - // Exit if the hash isn't a search query or there's an error in the query + // If the hash isn't a search query or there's an error in the query, + // then adjust the scroll position to account for sticky header, then exit. if ((location.hash.indexOf("q=") == -1) || (query == "undefined")) { // If the results pane is open, close it. if (!$("#searchResults").is(":hidden")) { hideResults(); } + // Adjust the scroll position to account for sticky header + $(window).scrollTop($(window).scrollTop() - 60); return; }