Skip to content

Instantly share code, notes, and snippets.

@fleeting
Created June 9, 2011 14:45
Show Gist options
  • Save fleeting/1016864 to your computer and use it in GitHub Desktop.
Save fleeting/1016864 to your computer and use it in GitHub Desktop.
Parallax
var animateDelay = 0;
var animationDelay = 2500;
function switchImage() {
$("#slider .currentSlide").fadeOut(1300, function() {
$(this).removeClass("currentSlide").prev().addClass("currentSlide");
li = $(this).detach();
li.removeAttr("style").find("img").removeAttr("style");
li.prependTo("#slider");
parallaxGo();
});
}
function parallaxGo() {
$("#slider li:last .bottom").delay(animateDelay).animate({
marginLeft: $("#slider li:last .bottom").attr("rel")
}, animationDelay, "linear");
$("#slider li:last .middle").delay(animateDelay).animate({
marginLeft: $("#slider li:last .middle").attr("rel")
}, animationDelay, "linear");
$("#slider li:last .top").delay(animateDelay).animate({
marginLeft: $("#slider li:last .top").attr("rel")
}, animationDelay, "linear");
}
$(document).ready(function() {
setInterval("switchImage()", 5500);
parallaxGo();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment