Skip to content

Instantly share code, notes, and snippets.

@hidaytrahman
Created April 13, 2015 10:10
Show Gist options
  • Save hidaytrahman/f0f5d1848d470d43f0a1 to your computer and use it in GitHub Desktop.
Save hidaytrahman/f0f5d1848d470d43f0a1 to your computer and use it in GitHub Desktop.
Custom parallax effect for all modern browser computability with simple code.
//Hidayt Rahman - UI Developer
//Custom Parallax effect
$(window).bind("load resize scroll",function(e) {
var y = $(window).scrollTop();
$(".bg").filter(function() {
return $(this).offset().top < (y + $(window).height()) && $(this).offset().top + $(this).height() > y;
}).css('background-position', '0px ' + parseInt(-y / 9) + 'px');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment