Created
February 7, 2018 14:41
-
-
Save juanbrujo/207c96fff510ca316ef4cd36b8b2f824 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
const title = document.querySelector('h1.title'); | |
const speed = 0.2; | |
title.style.transform = 'translateY( calc( var(--scrollparallax) * 1px ) )'; | |
function setScrollParallax() { | |
title.style.setProperty("--scrollparallax", (document.body.scrollTop || document.documentElement.scrollTop) * speed); | |
window.requestAnimationFrame( setScrollParallax ); | |
} | |
window.requestAnimationFrame( setScrollParallax ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment