Disable links until animation is finished to avoid fast clicking on menu that ruins the slideshow
I have a slideshow with jQuery Cycle. I've manipulated it quite a bit, so it works totally different than it does by standard.
Now I have a problem. If you click fast though the menu, that activates the slides, it will ruin the slideshow. I need to deactive the menu, until the animations are done. I have a "After-animation" space, where I could put in a "ready"-function of some kind. I just don't know how to.
$('.slideshow').cycle({
after: function(curr,next,opts) {
//here I can add a "Ready" function i guess
}
});
Menu: //This is the menu I use. I guess I could add a "Disable menu" rule in here, but again... I don't know how to... :-(
$('#menu li a').click(function() {
window.location.hash = $(this).attr('href');
开发者_如何学JAVA//$('.slideshow').cycle($(this).parent().index());
index = $(this).parent().index();
return false;
});
Or do you have another idea?
this might work.... not tried it though...
var ready = false;
$('.slideshow').cycle({
after: function(curr,next,opts) {
//here I can add a "Ready" function i guess
ready = true;
}
});
$('#menu li a').click(function() {
if (! ready ) { return false; }
window.location.hash = $(this).attr('href');
//$('.slideshow').cycle($(this).parent().index());
index = $(this).parent().index();
ready = false;
return false;
});
You could simply show/hide a transparent div with high z-index value that would disable links on your page as described here:
http://fczaja.blogspot.com/2009/02/disable-all-page-elements-with.html
精彩评论