Created
March 26, 2014 05:40
-
-
Save joshfry/9777443 to your computer and use it in GitHub Desktop.
Easy Parallax
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
(function($){ | |
function parallax() { | |
var scrolled = $(window).scrollTop(); | |
$('.parallax') | |
.css('top', 'calc(140px + ' + (scrolled * .6) + 'px)') | |
.css('opacity', 1 - (scrolled * .003)); | |
}; | |
parallax(); | |
$(window).scroll(function(){ | |
parallax(); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment