Skip to content

Instantly share code, notes, and snippets.

@samstefan
Created January 20, 2014 12:36
Show Gist options
  • Save samstefan/8519228 to your computer and use it in GitHub Desktop.
Save samstefan/8519228 to your computer and use it in GitHub Desktop.
imageParallax
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