我已经创建了jQuery动画的对象字面值,并且正在寻找将此传递给animate()
的简洁方法。.apply()方法不适用于jQuery .animate()
不幸的是,.apply()
似乎并没有与animate()
所以我必须工作诉诸使用索引 - 我想知道这是为什么,我怎样才能得到它与.apply()
工作。
var animations = {
slideLeft : function (moveLeft) {
return [{
left: moveLeft
}, {
duration: 300,
easing: 'swingy'
}];
}
};
$randomEl.animate.apply(this, animations.slideLeft(100)); // doesn't work
$randomEl.animate(animations.slideLeft(100)[0], animations.slideLeft(100)[1]); // does work
完美的作品,谢谢! – techjacker 2012-01-04 10:46:05