Created
June 2, 2016 13:19
-
-
Save iamkevingreen/82971e720559fae028efa8413fdbfd44 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
let scrollPosition = 0; | |
let setPosition = () => { | |
if (window.pageYOffset !== undefined) { | |
scrollPosition = window.pageYOffset; | |
} else { | |
scrollPosition = (document.documentElement || document.body.parentNode || document.body).scrollTop; | |
} | |
}; | |
let parallax = (el, divisble) => { | |
setPosition(); | |
el.style.transform = "translate3d(0px, "+(scrollPosition / divisble)+"px, 0px)"; | |
} | |
let handleScrolling = () => { | |
parallax(imageFloatOne, -6); | |
parallax(imageFloatTwo, -4.3); | |
parallax(imageFloatThree, -2); | |
parallax(earnedImageTwo, -6); | |
parallax(sparkText, -13); | |
parallax(heroText, -13); | |
} | |
window.addEventListener('scroll', handleScrolling); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment