Search code examples
jqueryjquery-uijquery-pluginsjquery-animateshow-hide

jQuery slideToggle, show/hide speed


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

Thanks.


Solution

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