fix(anchor): use scrollIntoView to reset scroll offset

resolve #2
This commit is contained in:
Dolphin Wood
2017-06-02 16:28:23 +09:00
parent 1f5d61a25c
commit e521ba732f
2 changed files with 6 additions and 8 deletions
+3 -4
View File
@@ -175,13 +175,12 @@
var currentHash = location.hash;
if (currentHash) {
// fix hash
setTimeout(function () {
location.hash = '';
location.hash = currentHash;
var anchor = document.getElementById(currentHash.slice(1));
if (anchor) anchor.scrollIntoView();
}, 0);
}
return $(this);
};
}));
}));
+3 -4
View File
@@ -133,10 +133,9 @@
var currentHash = location.hash;
if (currentHash) {
// fix hash
setTimeout(function () {
location.hash = '';
location.hash = currentHash;
var anchor = document.getElementById(currentHash.slice(1));
if (anchor) anchor.scrollIntoView();
}, 0);
}
@@ -150,4 +149,4 @@
} else {
window.initTOC = initTOC;
}
}(window));
}(window));