Last active
February 3, 2017 19:24
-
-
Save alairock/9c54ab040f280ec7bc7b to your computer and use it in GitHub Desktop.
Custom parallax effect
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
/** | |
* Main JS file for Casper behaviours | |
*/ | |
$(document).ready(function(){ | |
var lastScrollTop = 0; | |
$(window).scroll(function(event){ | |
var st = $(this).scrollTop(); | |
var scrolli = st/1.5; | |
scrollicious = $(".cover-image > img").css({"top": scrolli + "px"}); | |
if (st > lastScrollTop){ | |
scrollicious; | |
} else { | |
scrollicious; | |
} | |
lastScrollTop = st; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment