Created
September 12, 2011 10:51
-
-
Save mattboon/1211002 to your computer and use it in GitHub Desktop.
jQuery Animation
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
// Home animation | |
///------------------------------------------------------------- | |
// set the elements | |
$("#splash img").remove(); | |
$("#splash").append('<div></div><em></em>'); | |
animImg = $("#splash div"); | |
animText = $("#splash em"); | |
// define text for slides | |
var text1 = 'look deeper'; | |
var text2 = 'making sense of your world'; | |
var text3 = 'developing the whole'; | |
var text4 = 'together we can'; | |
var text5 = 'shaping the future'; | |
// set animation parameters | |
var slideCount = 1; | |
var faster = 1000; | |
var slower = 2000; | |
var readDelay = 2000; | |
function animateSlides() { | |
// hide again for security | |
animImg.css("opacity",0); | |
animText.css("opacity",0); | |
// set slide for animation | |
animImg.removeClass(); | |
animText.removeClass(); | |
animImg.addClass("image-"+ slideCount +""); | |
animText.addClass("text-"+ slideCount +""); | |
animText.html(eval("text"+slideCount)); | |
// set animation item | |
animItem = animImg; | |
// fade in the image | |
animItem.animate({ | |
opacity: 1 | |
}, slower, function() { | |
// callback | |
// set animation item | |
animItem = animText; | |
// fade in the text | |
animItem.animate({ | |
opacity: 1 | |
}, slower, function() { | |
// callback | |
// set animation item | |
animItem = animText; | |
// fade out the text | |
animItem.delay(readDelay).animate({ | |
opacity: 0 | |
}, slower, function() { | |
// callback | |
// set animation item | |
animItem = animImg; | |
// fade out the image | |
animItem.animate({ | |
opacity: 0 | |
}, slower, function() { | |
// callback | |
if(slideCount == 5) { | |
slideCount = 1; | |
} | |
else { | |
slideCount++; | |
} | |
// loop over | |
animateSlides(); | |
}); | |
}); | |
}); | |
}); | |
}; | |
animateSlides(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment