Last active
April 2, 2020 06:55
-
-
Save romannmk/1a1a4b17ee1f53c515ef733499820cbc to your computer and use it in GitHub Desktop.
Skew on scroll
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
React.useEffect(() => { | |
const section = pageRef.current | |
let currentPixel = window.pageYOffset | |
const looper = () => { | |
const newPixel = window.pageYOffset | |
const diff = newPixel - currentPixel | |
const speed = diff * 0.01 | |
if (section) { | |
section.style.transform = `skewY(${speed}deg)` | |
} | |
currentPixel = newPixel | |
requestAnimationFrame(looper) | |
} | |
looper() | |
}, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment