Skip to content

Instantly share code, notes, and snippets.

@voxpelli
Created March 11, 2010 10:42
Show Gist options
  • Save voxpelli/329029 to your computer and use it in GitHub Desktop.
Save voxpelli/329029 to your computer and use it in GitHub Desktop.
When an elements dimension changes it looks so much better if that change is animated - this snippet does that for any height changes
var animateChange = function (elem, func, speed) {
var origHeight, goalHeight;
origHeight = elem.innerHeight();
func(elem);
goalHeight = elem.height();
if (origHeight !== goalHeight) {
elem.height(origHeight).animate({height : goalHeight}, speed ? speed : 400, function () {
elem.height('auto');
});
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment