Home › Forums › JavaScript › Help with unbind then bind again after animation sequence
- This topic is empty.
-
AuthorPosts
-
September 1, 2011 at 4:50 pm #34181boxadesignMember
Hey all,
I have the following js function and I would like to prevent anything from happening and queueing once the click event has happened. Then when the function ends allow the click event to happen again.
$(“#tweet_activate a”).click(function(){
if($(‘body’).hasClass(‘home’)) {
$(this).parent().stop(true,true).animate({top: “+=154”}, 400).delay(1200).fadeOut();
} else {
$(“#int_comp”).animate({width: “+=157”}, 100);
$(this).parent().stop(true,true).animate({top: “+=154”}, 400).delay(1200).fadeOut();
}
$(“#tweet_text”).delay(400).animate({right: “+=56”}, 400);
$(“#tweet”).delay(900).animate({right: “+=214”}, 400);
$(“#tweet_deactivate”).delay(1200).fadeIn();
$(“#tweet_text p, #tweet_text span, #tweet #links”).delay(1200).fadeIn();
$(“#eye”).delay(600).fadeOut();
return false;
});$(“#tweet_deactivate a”).click(function(){
if($(‘body’).hasClass(‘home’)) {
} else {
$(“#int_comp”).animate({width: “-=157”}, 400);
}
$(“#tweet_text p, #tweet_text span, #tweet #links”).fadeOut();
$(“#tweet”).stop(true,true).animate({right: “-=214”}, 400);
$(“#tweet_text”).delay(400).animate({right: “-=56”}, 400);
$(this).parent().delay(900).animate({top: “-=154”}, 400).delay(200).fadeOut()
.delay(600).animate({top: “+=154”}, 100);
$(“#tweet_activate”).animate({top: “-=154”}, 500).delay(650).fadeIn();
$(“#eye”).delay(1000).fadeIn();
return false;
});The site is here – http://danielhollandphotography.com/
If you click on the ‘plus’ sign on the right icon grid you’ll see the sequence happen. If you click the icon mid way through you’ll see it fire again.
Thanks, Matt
September 1, 2011 at 5:34 pm #86139boxadesignMemberFixed with this code for those interested….
var animating = false;
$(“#tweet_activate a”).click(function() {
if (animating !== true) {
animating = true;
if ($(‘body’).hasClass(‘home’)) {
$(this).parent().stop(true, true).animate({
top: “+=154”
}, 400).delay(1200).fadeOut();
} else {
$(“#int_comp”).animate({
width: “+=157”
}, 100);
$(this).parent().stop(true, true).animate({
top: “+=154”
}, 400).delay(1200).fadeOut();
}
$(“#tweet_text”).delay(400).animate({
right: “+=56”
}, 400);
$(“#tweet”).delay(900).animate({
right: “+=214”
}, 400);
$(“#tweet_deactivate”).delay(1200).fadeIn();
$(“#tweet_text p, #tweet_text span, #tweet #links”).delay(1200).fadeIn();
$(“#eye”).delay(600).fadeOut(function() {
animating = false;
});
}
return false;
});
$(“#tweet_deactivate a”).click(function(){
if (animating !== true) {
animating = true;
if($(‘body’).hasClass(‘home’)) {
} else {
$(“#int_comp”).animate({
width: “-=157”
}, 400);
}
$(“#tweet_text p, #tweet_text span, #tweet #links”).fadeOut();
$(“#tweet”).stop(true,true).animate({
right: “-=214”
}, 400);
$(“#tweet_text”).delay(400).animate({
right: “-=56”
}, 400);
$(this).parent().delay(900).animate({
top: “-=154”
}, 400).delay(200).fadeOut()
.delay(600).animate({
top: “+=154”
}, 100);
$(“#tweet_activate”).animate({
top: “-=154”
}, 500).delay(650).fadeIn();
$(“#eye”).delay(1000).fadeIn(function() {
animating = false;
});
}
return false;
}); -
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.