🐛 修復上次更新導致頁面跳動的bug

This commit is contained in:
Jerry
2020-04-30 00:32:43 +08:00
Unverified
parent 250181c569
commit e8a47d040a

View File

@@ -532,11 +532,11 @@ $(function () {
}, 100) }, 100)
} }
var updateAnchor = function (anchor) { // function updateAnchor (anchor) {
if (anchor !== window.location.hash) { // if (window.history.replaceState && anchor !== window.location.hash) {
location.replace(window.location.href.split('#')[0] + anchor) // window.history.replaceState(null, null, anchor)
} // }
} // }
// find head position & add active class // find head position & add active class
// DOM Hierarchy: // DOM Hierarchy:
@@ -565,7 +565,7 @@ $(function () {
var currentActive = $('.toc-link.active') var currentActive = $('.toc-link.active')
if (currentId && currentActive.attr('href') !== currentId) { if (currentId && currentActive.attr('href') !== currentId) {
updateAnchor(currentId) // updateAnchor(currentId)
$('.toc-link').removeClass('active') $('.toc-link').removeClass('active')