Skip to content

Instantly share code, notes, and snippets.

@romannmk
Last active April 2, 2020 06:55
Show Gist options
  • Save romannmk/1a1a4b17ee1f53c515ef733499820cbc to your computer and use it in GitHub Desktop.
Save romannmk/1a1a4b17ee1f53c515ef733499820cbc to your computer and use it in GitHub Desktop.
Skew on scroll
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