Created
September 14, 2023 22:36
-
-
Save ealmloff/7797f6abfb57167cf99c564f6cd256ca to your computer and use it in GitHub Desktop.
This file contains 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
window.addEventListener('scroll', () => { | |
let scrollTop = window.scrollY; | |
let winHeight = window.document.documentElement.scrollHeight - window.document.documentElement.clientHeight; | |
let new_scroll = Math.min(Math.max(scrollTop, 0) / Math.max(winHeight, 1), 1); | |
document.body.style.setProperty('--scroll', new_scroll); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment