Created
February 11, 2014 14:33
-
-
Save JTLR/8935901 to your computer and use it in GitHub Desktop.
Really simple jquery parallax background
This file contains hidden or 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
var body; | |
var backgroundPosition; | |
var scrollPosition; | |
var parallaxAmount = 6; | |
$(document).ready(function () { | |
body = $('body'); | |
}); | |
$(window).scroll(function () { | |
scrollPosition = $(window).scrollTop(); | |
bkgPos = -(Math.floor(scrollPosition/parallaxAmount)); | |
body.css('background-position', 'center ' + backgroundPosition + 'px'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment