Skip to content

Instantly share code, notes, and snippets.

@edheltzel
Forked from murtaugh/parallax.js
Last active August 29, 2015 14:09
Show Gist options
  • Save edheltzel/fa8e9d138ce03b43cbd5 to your computer and use it in GitHub Desktop.
Save edheltzel/fa8e9d138ce03b43cbd5 to your computer and use it in GitHub Desktop.
$(window).scroll(function(e){
parallax();
});
function parallax() {
var scrolled = $(window).scrollTop();
//81% is the original top position of the element,
// which could be made into a variable onload instead
$('#foo').css('top', 'calc(81% - ' + (scrolled * .2) + 'px)');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment