开发者

jQuery slideToggle, show/hide speed

开发者 https://www.devze.com 2023-01-13 01:29 出处:网络
Is there anything in j开发者_如何转开发Query that allows you to specify the speed of a show/hide effect (as opposed to its duration).

Is there anything in j开发者_如何转开发Query that allows you to specify the speed of a show/hide effect (as opposed to its duration).

Thanks.


To build on Yi Jiangs comment, speed is a function of distance and duration, lets say you want it to expand at say 200px/s to do that you need to use element height and basic calculus to figure out how long the animation should take, if your element is 300px high animation duration should be:

300/200 = 1.5 seconds or 1500ms, now apply that to http://api.jquery.com/slideToggle/ and we have a winner.


You can do:

.hide("slow")
.hide("fast")

There is no real difference between speed and duration in this situation. If the duration is short, then it's fast (higher speed).


Constant speed:

$element.slideToggle($element.height());
0

精彩评论

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