不打算在插件太深,你可以重複使用您css3animate
方法使用當前(計算)你想要的道具值,設定時間爲0(1,因爲你在你的插件使用!speed
使用
var $animated = $('div');
$animated.css3animate({"height": $animated.css('height'), "width": $animated.css('width')}, 1);
會做的伎倆使用默認..)
所以這個例子。在http://jsfiddle.net/T5LVX/1/
當然
例如,您應該爲當前使用的特性自動完成這個。如果你使用一個計時器,當您啓動動畫,另一個當有人使用停止方法,也可以模擬一個暫停/恢復功能..
更新
您可以存儲通過cssObject
到動畫,到元素的data
,並通過停止循環來獲取當前值。
所以你animation
方法你可以$obj.data('animationCss', cssObject);
並在stop
方法
stop : function(clearQueue,jumpToEnd){
return this.each(function(){
var $that = $(this);
var currentCss = {};
var animationCss = $that.data('animationCss');
for (var prop in animationCss)
currentCss[prop] = $that.css(prop);
if (jumpToEnd)
{
animation($that,currentCss,1, function(){animation($that,animationCss,1)});
}
else
{
animation($that,currentCss,1);
}
console.log("stop was called");
});
}
例如:http://jsfiddle.net/T5LVX/6/
你想阻止它* -as在保持其當前LEVEL- *(*暫停*)還是跳過動畫到最後? – 2011-03-15 13:42:14
我想實現這兩個,所以我打開任何形式的輸入'.stop(false,ture)'和'.stop(false,false)' – meo 2011-03-15 13:42:54