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());
精彩评论