Created
April 13, 2015 10:10
-
-
Save hidaytrahman/f0f5d1848d470d43f0a1 to your computer and use it in GitHub Desktop.
Custom parallax effect for all modern browser computability with simple code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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