I have a script that I am developing that creates a sliding button type effect. Five div\'s are situated next to eachother each with a link. When one of those DIVS are click
(function() {
var mutex = false;
function mnuClick(x){
if (!mutex) {
mutex = !mutex;
/* all code here ... */
mutex = !mutex; /* this statement should go into animation callback */
}
}
})();
mantain a state through a variable so you cannot click more than once until code has fully executed
you can create an invisible maskin and maskout ( like the background in lightbox etc ) or disable clicks until the animation finishes.
you can unplug the onClick event handler (mnuClick) when the event starts, to effectively disable invoking the mnuClick twice, but be sure to restore it when the event ends.
Quick answer: use .addClass and .removeClass and test for the existence of the class at execution time. Test if it's set and return, or add it, execute the code, then remove it.
You need a "isRunning" flag. Check for it before you start. Set it when you start the sequence, clear it when it ends.