Last active
August 29, 2015 14:01
-
-
Save dominikwilkowski/68e8ab71952a235eb127 to your computer and use it in GitHub Desktop.
JS animate to auto function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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