From 06f3f2c14831fc7e99c629cddbf96fcc7b1f829c Mon Sep 17 00:00:00 2001 From: Scott Main Date: Fri, 30 May 2014 11:23:00 -0700 Subject: [PATCH] fix bug in chrome with anchors not scrolling into view on new pages. added a 100ms delay to the scroll offset because chrome does not immediately scroll the page to the anchor on page load. Change-Id: Ib10cfecfe63d9d9220170842f4c8941557c0eb06 --- tools/droiddoc/templates-sdk/assets/js/docs.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js index 95acec496a..231ac4c96b 100644 --- a/tools/droiddoc/templates-sdk/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk/assets/js/docs.js @@ -494,7 +494,11 @@ false; // navigate across topic boundaries only in design docs } } + // Resize once loading is finished resizeNav(); + // Check if there's an anchor that we need to scroll into view. + // A delay is needed, because some browsers do not immediately scroll down to the anchor + window.setTimeout(offsetScrollForSticky, 100); /* init the language selector based on user cookie for lang */ loadLangPref(); @@ -998,10 +1002,6 @@ $(window).scroll(function(event) { $cardInfo.css({position: 'absolute', bottom:'0px', left:'0px', right:'0px', overflow:'visible'}); }); - // Resize once loading is finished - resizeNav(); - // Check if there's an anchor that we need to scroll into view - offsetScrollForSticky(); }); })(); @@ -2525,7 +2525,6 @@ function offsetScrollForSticky() { // to be because we need to move it down 60px to become in view), then move it down 60px if (Math.abs($matchingElement.offset().top - $(window).scrollTop()) < 20) { $(window).scrollTop($(window).scrollTop() - 60); - } else { } } }