views:

90

answers:

2

Is there anything in jQuery that allows you to specify the speed of a show/hide effect (as opposed to its duration).

Thanks.

A: 

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).

marcgg
+1  A: 

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.

Kristoffer S Hansen
I was taking this approach and I'm not convinced it is giving properly consistent results. Maybe it's just an optical illusion though. I'll leave it like this for now.
fearofawhackplanet
`$(this).slideToggle($(this).height());`
fearofawhackplanet