Created
January 20, 2014 12:36
-
-
Save samstefan/8519228 to your computer and use it in GitHub Desktop.
imageParallax
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
this.imageParallax = function () { | |
$(window).scroll(function () { | |
var windowPosition = $(window).scrollTop(); | |
function parallax(topHeight, windowPosition, inertia){ | |
return topHeight - windowPosition / inertia; | |
} | |
$('.js-parallax img').css( | |
'-webkit-transform', 'translate3d(0, ' + parallax(0, windowPosition, 4) + 'px, 0)' | |
) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment