0

このプラグインにイージングを追加する方法を教えてもらえますか?イージングプラグイン、yada yadaがあることを理解しています。このプラグインに、使用時にイージングとコールバックを追加するオプションが必要です。easingの後に単語を追加してみたspeed,ので、のように見えましspeed, easing, callbackたが、どういうわけかうまくいきませんでしたか?

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);
    });  
}
4

1 に答える 1

1

次のようになります。


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

このような意味ですか

于 2012-01-27T06:44:38.623 に答える