3

Is it possible to somehow specify the speed of toggle('blind') animation?

My problem is this: I use it to display dynamic content, so I usually don't know the exact size of the element that is to be displayed. Since the animation speed is dependent on both 'duration' argument and the size of element, which is variable, I cannot control the speed itself.

My solution: Use the obj.toggle('blind', obj.height() / x) where x is the desired speed in pixels per millisecond. Is this solution acceptable?

Stas Bichenko
  • 13,013
  • 8
  • 45
  • 83
  • Yes, I can't see a reason why that wouldn't work. – Rory McCrossan Apr 06 '12 at 13:22
  • So, what if I initially show it for a moment, register the height, then immediately hide it, and then `toggle()` it using the method described above? I wonder if some users will be able to notice the initial display, esp. those on weaker computers. – Stas Bichenko Apr 06 '12 at 13:27
  • 1
    On second thought, scratch my first comment: I performed a quick test and the `blind` effect is apparently smart enough to restore the initial height after hiding the item, so `height()` will always return a meaningful value. Therefore, your solution seems to work in all cases. – Frédéric Hamidi Apr 06 '12 at 13:36
  • 1
    This behavior is explained here: http://stackoverflow.com/a/3632290/710356 – Stas Bichenko Apr 06 '12 at 15:42

1 Answers1

1

My solution seems to be correct:

Use the obj.toggle('blind', obj.height() / x) where x is the desired speed in pixels per millisecond.

height() will always return a meaningful value. This behavior is explained here

Community
  • 1
  • 1
Stas Bichenko
  • 13,013
  • 8
  • 45
  • 83