Created
May 7, 2025 13:29
-
-
Save Megafry/2c1f7a733f734d690f3a094718874a1a to your computer and use it in GitHub Desktop.
Stop using window.scrollTo(), Use the new scrollIntoView, this will also take into consideration the scroll-padding defined in CSS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
button.addEventListener('click', e => { | |
const targetEl = document.getElementById("footer") | |
targetEl.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'start'}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment