jQuery :visible is true while executing hiding animations -
I know that it's going to behave like this, but when I'm trying to determine visibility, one element while doing this I'm in the process of hiding (or showing that when I'm animated 'true' is inverted, it shows.)
Then how can I use jQuery to determine I see that an element is visible, with the warning that the element is currently visible, but itself Micro hidden (current behavior to hide the process) and is considered the visible elements in the process of looking themselves (current behavior)?
The problem is worse than the fact that for testing: jQuery is visible in events, so there is no direct code path where element is shown / where visibility check is required. Therefore, I just can not pass the animation status between all the functions.
There are some code to clarify this problem:
& lt; Html xmlns = "http: //www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Var spn, result 1, result 2, last delayed result, last reset result; $ (Document) .ready (function () {spn = $ ('# spn'); result1 = $ ('# result1'); result 2 = $ ('# result2');}); Function toggles () {explicit timed out (last delay result); ClearTimeout (lastResetResults); Result2.text (""); Spn.slideToggle (); Result1.text ("Text is" + Visibility () + "."); Last delimited result = settimeout (function () {delayedResult ();}, 1000); LastResetResults = Settimeout (function () {resetResults ();}, 3000); } Function visibility () {return (spn.is (': visible'))? "Visible": "hidden"; } Function delayed result () {result2.text ("text after one second" + "visibility +"); } Reset the function () {result1.text (""); Result2.text (""); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Span id = "result1" & gt; & Lt; / Span & gt; & Amp; Nbsp; & Lt; Span id = "result2" & gt; & Lt; / Span & gt; & Lt; Hours / & gt; & Lt; Input id = "btn" name = "btn" type = "button" onclick = "toggle ();" Value = "Click me!" / & Gt; & Lt; Br / & gt; & Lt; Span id = "spn" & gt; I am the lesson! & Lt; / Span & gt; & Lt; / Body & gt; & Lt; / Html & gt; It is possible to use the animation callback methods to guarantee the final position of the element is possible.
Comments
Post a Comment