So this might be really simple, but I haven’t been able to find any examples to learn off of yet, so please bear with me. 😉
Here’s basically what I want to do:
<div>Lots of content! Lots of content! Lots of content! ...</div> .... $('div').html('Itsy-bitsy bit of content!');
I want to smoothly animate between the dimensions of the div with lots of content to the dimensions of the div with very little when the new content is injected.
Thoughts?
Try this jQuery plugin:
Commenter RonLugge points out that this can cause problems if you call it twice on the same element(s), where the first animation hasn’t finished before the second begins. This is because the second animation will take the current (mid-animation) sizes as the desired ‘ending’ values, and proceed to fix them as the final values (effectively stopping the animation in its tracks rather than animating toward the ‘natural’ size)…
The easiest way to resolve this is to call
stop()before callingshowHtml(), and passingtruefor the second (jumpToEnd) parameter:This will cause the first animation to complete immediately (if it is still running), before beginning a new one.