jQuery - Disable Click until all chained animations are complete

后端 未结 6 1073
无人共我
无人共我 2020-12-05 00:27

Question

The solution below is intended to slide down the groupDiv displaying div1 and enough space for

6条回答
  •  离开以前
    2020-12-05 01:16

    The issue is your first animating the div#GroupDiv so your initial check if (!$("#div2 .tab").is(':animated')) will be false until the groupDiv has finished animated and the callback is fired.

    You could maybe try

    if (!$("#div2 .tab").is(':animated') && !$("#GroupDiv").is(':animated')) 
    

    however I doubt this will cover really quick clicking. The safest is to unbind the event using

    $(this).unbind('toggle').unbind('click');

    as the first line inside the if and you can then do away with the animated check. The downside to this is you will have to rebind using the callback you are passing through to your custom animation functions.

提交回复
热议问题