android.nick
android.nick

Reputation: 11197

Add easing to a simple little jquery plugin? not working

Can someone tell me how to add easing to this plugin. I understand there's an easing plugin, yada yada, I just want this plugin to have the option of adding easing AND a callback when using it. I tried adding the word easing after speed,, so it looked like speed, easing, callback, but for some reason it didn't work?

jQuery.fn.animateAuto = function(prop, speed, callback){
    var elem, height, width;
    return this.each(function(i, el){
        el = jQuery(el), elem = el.clone().css({"height":"auto","width":"auto"}).appendTo("body");
        height = elem.css("height"),
        width = elem.css("width"),
        elem.remove();

        if(prop === "height")
            el.animate({"height":height}, speed, callback);
        else if(prop === "width")
            el.animate({"width":width}, speed, callback);  
        else if(prop === "both")
            el.animate({"width":width,"height":height}, speed, callback);
    });  
}

Upvotes: 0

Views: 212

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

It should be like:


el.animate(
  {height:your_height_value}, 
  speed, 
  'swing', //example easing here
  complete: function() {  //your callback, just an example
    //do something
  }
);

Did you mean something like this

Upvotes: 1

Related Questions