Not an X animation If an X animation is already running (inside the keyboard)

The way it is currently written makes you hide the fire again and again if msg.d starts returning "false" from "true" until enough time has passed to stop the animation.

Is there anything or something?

Thanks in advance!

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

Change 1

This is all in the key handler.

Edit 2

Using animated only starts the animation when it is completed. If msg.d changes, but now the incorrect animation is not finished yet, the correct animation does not work.

Chrome Solution

I used a global boolean to track state. I hate doing it. Put generosity for the best deal when I can. Thanks everyone!

Canceled Reward

Sorry, the guys did not understand what I had to buy with my own representative. :(

+3
source share
4 answers

If you want to stop animation, medium animation and move it from the state of stop ped css to another, use, most importantly, stop(true, false) .

Bottom line: stop(true,false) "magically" stops the animation in its "tracks", but believes that css will be installed regardless of the parameters of the stopped css animation, so you can continue from this point without trying to guess or figure out how you should be animated from the point of the stop pen.

In other words, if you install css through animate , but you stop sharing it, the animated element will remain in any css stop state, but the css settings that were entered in the stop animation of the pedals will be the current css settings until it is changed.

This key. You do not need to guess where stop leaves the css state. You can continue as if your animation was complete.

This is a demonstration of the basics of this concept: http://jsfiddle.net/dYYZP/65/


Dropped the basic animation from here: The jQuery animation out of the way


Postscript

Due to the simplicity of animate , absolute positioning in relative , offset and stop(true,false) positioning, it rarely happens that I use any built-in animation. They are too clumsy and do not know what you really need. They are great for the most basic animations, but if you want your page to shine, these concepts above (which I can add very easily) should be used.

+2
source

You can check if it is animated in the animated selector.

http://api.jquery.com/animated-selector/

+1
source

As shown above, use ": 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); } 
+1
source

Perhaps you should use .stop().hide( and .stop.show( wherever you use hide and show .

+1
source

All Articles