Reputation: 11
I have an animation that I am running using jQuery. I am assuming a good way to only play this animation once for the visitor is by setting a cookie. I basically need it to say you've been here before so set all the IDs listed to opacity:1 Is there an ultra simple solution to this? Thanks for any help
$(document).ready(function(){
$("#featureFade").animate({opacity:1},400,function(){
$("#image").delay(300).animate({opacity:1},300,function(){
$("#title").delay(300).animate({opacity:1},300,function(){
$("#message, #move").delay(200).animate({opacity:1},300,function(){
$("#move").animate({top: '400px',left: '0px'}, 500,function(){
$("#nav,#contentContainer,#button,#footer,#topLevelNav").delay(1000).animate({opacity:1},700);
});
});
});
});
});
});
Upvotes: 1
Views: 1821
Reputation: 101604
Using the jQuery Cookie Plugin you can do this simply:
// check for previous visit
if ($.cookie('hasSeenAnimation') == null){
// ...
// play animation
// ...
// set cookie to stop next visit
$.cookie('hasSeenAnimation','true');
}
Upvotes: 2
Reputation: 11022
I would do it on the server side - if the cookie is set, just don't output the code for the animation...
Upvotes: 1