Don't Animate X If Animation X Already Running (inside keyup)

后端 未结 4 748
礼貌的吻别
礼貌的吻别 2020-12-06 15:04

The way it\'s currently written causes the hide to fire over and over if msg.d starts returning \'false\' from \'true\' until enough time has passed for the animation to sto

4条回答
  •  一个人的身影
    2020-12-06 15:45

    As above suggest use the ":animated" seclector

    if(msg.d == "true") {
        var contact = $("#addContactEmailError");
    
        if(!contact.is(":visible") && !contact.is(":animated")) {
             contact.show('bounce');
        }
        $("#addContactSubmitButton").attr("disabled", true);
    }
    else {
        if(contact.is(":visible") && !contact.is(":animated")) {
             contact.hide('slide', { direction: "up" });
        }
        $("#addContactSubmitButton").attr("disabled", false);
    }
    

提交回复
热议问题