jQueryアニメーションのオブジェクトリテラルを作成しました。これをanimate()
に渡す簡潔な方法を探しています。.apply()メソッドはjQueryで機能しません。アニメーション()
残念なことに、は、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