Created
December 22, 2015 13:53
-
-
Save technbuzz/5f1405d7ef33cd192db3 to your computer and use it in GitHub Desktop.
Simple Parallax Scrolling
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
/////////////////////////////////////////// | |
// Paralax Effect | |
//////////////////////////////////////////// | |
var el = document.getElementById('header-image'); | |
window.addEventListener('scroll', function(){ | |
var yPos = -(window.scrollY / 15); | |
var coords = '50% ' + yPos + 'px'; | |
el.style.backgroundPosition = coords; | |
console.log(coords); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment