jQuery hover animation - how to stop properly on mouseout -


My problem is that when I take the mouse quickly on the square element and then exit my cursor Sometimes the "mouseout" part of the hover function

My HTML:

  & lt; Div id = "wrapper" & gt; & Lt; Div id = "o1" square = "square" & gt; & Lt; / Div & gt; & Lt; Div id = "o2" square = "square" & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

CSS

  #wrapper {width: 100px; Height: 100 pixels; Status: Relative; } .square {width: 100px; Height: 100 pixels; Status: Completed; } # O1 {background: red; } # O2 {background: blue; display none; Javascript:  
  $ (function () {var o1 = $ ("# o1"); var o2 = $ ("# o2" ); $ ('# Wrapper') Hover (function () (o1.fadeOut (400, function) (o2.fadeIn (400);})}}, function () {o2.fadeOut (400, function) {O1 .fadeIn (400);});});});   

jsFiddle:

I tried to use stop () with different parameters at different places in my code but without Of success Thank you

I came up with the easiest solution to ensure that all the queue any new animation :

  var o1 = $ ("# o1"); Var o2 = $ ("# o2"); $ ('# Wrapper'). Hover (function {o2.stop (true, true); o1.stop (true, true); o1.fadeOut (400, function) (o2.fadeIn (400);});}, function () {O1.stop (true, true); o2.stop (true, true); o2.fadeOut (400, function) (o1.fadeIn (400);});});   

Please note the following sequence of order related matters while pausing the queue:

  o1.fadeOut (400, Function) (o2.fadeIn (400);}); O2.stop (true, true); // At this point, o1 can still queue a new animation on o2 / at this point, o1 fadeOut () may end and o2.fadeIn () o1.stop (true, true) may start ; // We should have stopped this first    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -