I noticed a bit of an oddity when playing around with the hover state of an
object and animations that I'd like to describe.

First, I'll give you some sample code.  In my body, I have the following two
links:


        <a href="#"
style="display:block;height:100px;width:100px;line-height:100px;background-color:red;text-align:center;"
class="zero">zero</a>
        <br />
        <a href="#"
style="display:block;height:100px;width:100px;line-height:100px;background-color:red;text-align:center;"
class="one">one</a>


the class names and text refer to the number of milliseconds on hover that
the opacity should change from its initial state (40%) to 100%.

In the header, along with a script tag linking in the latest version of
jquery, I have the following in a ready function:


        $(".zero").animate({ opacity : 0.4 },0).hover( function(){
                $(this).stop().animate({ opacity : 1 },0);
        }, function(){
                $(this).animate({ opacity : 0.4 },500);
        });
        $(".one").animate({ opacity : 0.4 },0).hover( function(){
                $(this).stop().animate({ opacity : 1.0 },1);
        }, function(){
                $(this).animate({ opacity : 0.4 },1000);
        });


Class zero gets initially set to 40% opacity over 0ms.  Upon hover over the
opacity should get set to 100% over 0ms (immediately), but instead the
animation takes the default duration to complete.

Class one is the same as class zero, but the haver animation takes one
millisecond to execute and works much like class zero was originally
intended.

The interesting thing I noticed was that outside the hover event, the
duration of 0ms seemed to be handled correctly, but inside the hover event,
0 was treated like a boolean false indicating no specified duration, thus
defaulting to the default animation duration (500ms?).

I'm looking for some validation before I report this as a bug, so if anyone
can take a few seconds to try out the above code and share your thoughts, It
would be greatly appreciated!
-- 
View this message in context: 
http://www.nabble.com/bug-with-animate-and-a-duration-of-0-milliseconds--tp15413274s27240p15413274.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to