mirror of https://github.com/zulip/zulip.git
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)
This commit is contained in:
parent
1141bfa888
commit
a9112155da
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue