How to implement jQuery's slideDown() with unknown height in plain JS

Viewed 2349

I am trying to implement a 'toggle visibility with sliding motion' functionality like jQuery's slideDown() in plain JS.

I can animate values over time, no problem, but what do I do when the height of the element that should become visible is unknown?

Existing sample solutions always seem to animate the max-height value up to a fixed value, but I need to animate to previously unknown value (height).

(If there's a way to achieve this with css3, I would also be curious!)

6 Answers
Related