Remove smooth scrolling preference check from back to top script
This commit is contained in:
parent
bfc592b8e6
commit
e5a1f860f0
|
@ -51,7 +51,6 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script defer>
|
<script defer>
|
||||||
{# Based on: https://jhartshorne.co.uk/posts/back-to-top/ #}
|
|
||||||
const topButton = document.querySelector(".top-btn");
|
const topButton = document.querySelector(".top-btn");
|
||||||
const scrollOffset = 400;
|
const scrollOffset = 400;
|
||||||
|
|
||||||
|
@ -63,14 +62,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollOptions = {
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
behavior: 'smooth'
|
|
||||||
};
|
|
||||||
const supportsNativeSmoothScroll = 'scrollBehavior' in document.documentElement.style;
|
|
||||||
|
|
||||||
topButton.addEventListener('click', () => {
|
topButton.addEventListener('click', () => {
|
||||||
supportsNativeSmoothScroll ? window.scrollTo(scrollOptions) : window.scrollTo(scrollOptions.left, scrollOptions.top);
|
window.scrollTo({ top: 0, left: 0 });
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue