开发者

jQuery: duration param fail in .animate() method

开发者_如何学运维The settings I set in the duration params in the following code are failing me (50, 1000, 4000). No matter the duration value I set it runs at a speed that looks to be half a second. Here is a link to a live demo - http://dekke.net/easing/easing.html. Here is the relevant code:

        $(function() {
        $("#animate").click(function() {
            $("#one").animate({ left: "500px" }, { duration: "50", easing: "linear"}, 0);
            $("#two").delay(500).animate({ left: "500px" }, { duration: "1000", easing: "linear"} ); 
            $("#three").delay(1000).animate({ left: "500px" }, { duration: "4000", easing: "linear"} );
        });

Any help here is greatly appreciated.


Instead of a string:

duration:"1000"

pass a number:

duration:1000

EDIT: A little more information.

Here's where the duration is analyzed. https://github.com/jquery/jquery/blob/1.5/src/effects.js#L283-284

Basically -

  • if it's a Number, use it
  • if not, assume it is a property of jQuery.fx.speeds ("slow", "fast")
  • if not, use the _default property of jQuery.fx.speeds

I'd think it would be useful if jQuery would attempt a parseInt() if it wasn't a Number just in case someone did pass a numeric string. Then if that returns NaN, try the jQuery.fx.speeds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜