Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dominikwilkowski
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominikwilkowski/68e8ab71952a235eb127 to your computer and use it in GitHub Desktop.
Save dominikwilkowski/68e8ab71952a235eb127 to your computer and use it in GitHub Desktop.
JS animate to auto function
jQuery.fn.animateHeightAuto = function(speed, callback) {
var height;
return this.each(function(i, $element) {
var $this = $( $element );
var heightBackup = $this.css('height');
$this.css({
'height': 'auto'
});
height = $this.css('height');
$this.css({
'height': heightBackup,
});
$this.animate({
'height': height,
}, speed, callback);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment