Created
March 5, 2014 16:06
-
-
Save murtaugh/9370183 to your computer and use it in GitHub Desktop.
Finally a simple parallax script I like
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
$(window).scroll(function(e){ | |
parallax(); | |
}); | |
function parallax() { | |
var scrolled = $(window).scrollTop(); | |
//81% is the original top position of the element, | |
// which could be made into a variable onload instead | |
$('#foo').css('top', 'calc(81% - ' + (scrolled * .2) + 'px)'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment