gespinha
gespinha

Reputation: 8497

Jquery slide effect speed instead of duration?

Is it possible to assing a speed instead of a duration value to a JQuery slide effect, so that elements with different sizes open or close at the same speed?

$(this).slideUp( /* SPEED instead of DURATION */ );

Upvotes: 1

Views: 225

Answers (1)

Jason P
Jason P

Reputation: 27022

I think this works... you can multiply the height of the item by some constant:

http://jsfiddle.net/4AdRH/

var constant = 4;

$('#div1').slideUp($('#div1').height() * constant);
$('#div2').slideUp($('#div2').height() * constant);

Adjust the constant to change the speed, but it will always be relative to the height of the element being animated.

Upvotes: 1

Related Questions