Skip to content

Instantly share code, notes, and snippets.

@radium-v
Created September 8, 2016 05:37
Show Gist options
  • Save radium-v/3fe6c0fbd052607bd7c0706214728db1 to your computer and use it in GitHub Desktop.
Save radium-v/3fe6c0fbd052607bd7c0706214728db1 to your computer and use it in GitHub Desktop.
var parallax = document.getElementById('js-parallax');
window.addEventListener('scroll', function(e) {
parallax.style.backgroundPosition = ['0 ', (window.pageYOffset - parallax.offsetTop) / 2, 'px'].join('');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment