Created
November 12, 2023 04:03
-
-
Save skwashd/19e5cec15a717db3abbaec1acaec3462 to your computer and use it in GitHub Desktop.
Safari doesn't support the behaviour property when calling window.scroll. This prevents smooth scrolling. Copy and paste this code into your JS console to get smooth scrolling. Great for screen capture videos.
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
const footerHeight = 800; | |
let pos = 0, | |
pageHeight = document.body.offsetHeight, | |
winHeight = window.innerHeight, | |
maxPos = pageHeight - winHeight - footerHeight; | |
function scrollWin() { | |
if (pos >= maxPos) { | |
console.log(`We're done at ${pos}`); | |
return; // bailout | |
} | |
pos += 20; | |
window.scroll({ | |
top: pos, | |
left: 0, | |
}); | |
setTimeout(scrollWin, 20) | |
} | |
// We need time to close the console | |
setTimeout(scrollWin, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment