Skip to content

Instantly share code, notes, and snippets.

@murtaugh
Created March 5, 2014 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save murtaugh/9370183 to your computer and use it in GitHub Desktop.
Save murtaugh/9370183 to your computer and use it in GitHub Desktop.
Finally a simple parallax script I like
$(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