Skip to content

Instantly share code, notes, and snippets.

@digitalicarus
Created September 17, 2012 18:52
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 digitalicarus/3739080 to your computer and use it in GitHub Desktop.
Save digitalicarus/3739080 to your computer and use it in GitHub Desktop.
fadey height
(function($){
$.fn.voila = function(content,cb) {
return this.each(function() {
var $this = $(this);
if($this.is(":visible")) {
//-- http://stackoverflow.com/questions/4085800/jquery-animate-changes-in-div-height-on-ajax-l
console.log("voila: origHeight="+$this.height());
$this
.animate({height: $this.height(), opacity: 'hide'}, 'fast', function(){
$(this).html(content)
})
.wrapInner('<div style="padding: 0; margin: 0"/>');
var newHeight = $('div:first',$this).height();
console.log("voila: newHeight="+newHeight);
$this.animate({height: newHeight, opacity: 'show'}, 'fast', 'linear', function(){
});
} else {
$this.html(content);
}
});
};
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment