From a9112155dac0edc8dc92f5749e5efeab987ba9ca Mon Sep 17 00:00:00 2001 From: Waseem Daher Date: Thu, 10 Jan 2013 11:21:19 -0500 Subject: [PATCH] Reset our scroll position if we change our hash to "#". Changing the hash to "#" causes Chrome to jump to the top of the page on Mac OS X. This commit doesn't actually fix any bug, but it is necessary for my *next* commit, where otherwise you'd have to ensure that the scroll code came *after* the hashchange code. (imported from commit 925b44d770c96dafaabebc9e0114f9a3b8f53c4d) --- zephyr/static/js/hashchange.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zephyr/static/js/hashchange.js b/zephyr/static/js/hashchange.js index ec00599de5..b6ce6e12bb 100644 --- a/zephyr/static/js/hashchange.js +++ b/zephyr/static/js/hashchange.js @@ -6,16 +6,17 @@ var expected_hash = false; exports.changehash = function (newhash) { expected_hash = newhash; - // Some browsers reset scrollTop when changing the hash to "", + // Some browsers reset scrollTop when changing the hash + // to "" or "#" (Mac Chrome, for example) // so we save and restore it. // http://stackoverflow.com/questions/4715073/window-location-hash-prevent-scrolling-to-the-top var scrolltop; - if (newhash === "") { + if (newhash === "" || newhash === "#") { scrolltop = viewport.scrollTop(); } window.location.hash = newhash; util.reset_favicon(); - if (newhash === "") { + if (newhash === "" || newhash === "#") { viewport.scrollTop(scrolltop); } };