Skip to content

Commit c9ce44b

Browse files
committed
disable smooth scroll behavior when jumping to fragment on page load
1 parent 6c6ce69 commit c9ce44b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/js/03-fragment-jumper.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
window.addEventListener('load', function jumpOnLoad (e) {
2525
var fragment, target
2626
if ((fragment = decodeFragment(window.location.hash)) && (target = document.getElementById(fragment))) {
27+
document.documentElement.style.scrollBehavior = 'auto'
2728
jumpToAnchor.bind(target)()
2829
setTimeout(jumpToAnchor.bind(target), 0)
30+
setTimeout(function () {
31+
document.documentElement.style.scrollBehavior = ''
32+
})
2933
}
3034
window.removeEventListener('load', jumpOnLoad)
3135
})

0 commit comments

Comments
 (0)