How would i abstract this code to block clicks while any animation is active?
I am using #cover to cover up the clickable divs while an animation is active. Using
$("#cover").hide(); /
$("#cover").show(); It is working. But I would like to do this for any animation that plays. Is there a way to abstract this code for any animated div?
- $(".clsStartUpNode").click(function() {
- $("#StartUpPosition div").not("#StartUpMainNode, #" + $divID).fadeOut(300); // fade out all starting nodes except center (CES) node
- $("#StartUpMainNode").stop().animate( {left:22}, function() {
- $("#StartUpMainNode").hide();
- $("#NodeMain").show(); //after that finishes, fade in the main CES node
- });
- $("#" + $divID).stop().animate( {left:152, top: 145}, function() {
- $("#" + $divID).hide();
- $("#NodeTwo").show(); //fade in the node clicked
- $.displaySubNodes($nodeID, 1)
- $("#cover").hide();
- });
- }
- });
I have tried using :animated. However, it only shows the cover div, and doesn't hide it once an animation completes. it works in the code above because the hide code is in the animation callback.
- if ( $('div').is(':animated') ) {
- $('#cover').show();
- }
- if( !$('div').is(':animated')){
- $("#cover").hide();
- }
Thank you!