Skip to content

Instantly share code, notes, and snippets.

@alairock
Last active February 3, 2017 19:24
Show Gist options
  • Save alairock/9c54ab040f280ec7bc7b to your computer and use it in GitHub Desktop.
Save alairock/9c54ab040f280ec7bc7b to your computer and use it in GitHub Desktop.
Custom parallax effect
/**
* 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