Skip to content

Instantly share code, notes, and snippets.

@eyy
Created January 9, 2014 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyy/8342633 to your computer and use it in GitHub Desktop.
Save eyy/8342633 to your computer and use it in GitHub Desktop.
easy parallax
// based on http://codepen.io/zitrusfrisch/pen/bJwhk
function easyParallax() {
var scrollPos = w.scrollTop();
$('#banner').css({
'background-position' : '50% ' + (-scrollPos/4)+"px"
});
$('#bannertext').css({
'margin-top': (scrollPos/4)+"px",
'opacity': 1-(scrollPos/250)
});
}
var w = $(window).scroll(easyParallax);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment