Skip to content

Instantly share code, notes, and snippets.

@itsmattsoria
Created November 27, 2013 09:26
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 itsmattsoria/7672974 to your computer and use it in GitHub Desktop.
Save itsmattsoria/7672974 to your computer and use it in GitHub Desktop.
Easy peasy parralax effect (http://codepen.io/eugene823/pen/vDqkC)
function EasyPeasyParallax() {
scrollPos = jQuery(this).scrollTop();
jQuery('#banner').css({
'background-position' : 'center ' + (-scrollPos/4)+"px"
});
jQuery('#bannertext').css({
'margin-top': (scrollPos/4)+"px",
'opacity': 1-(scrollPos/250)
});
}
jQuery(document).ready(function(){
jQuery(window).scroll(function() {
EasyPeasyParallax();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment