0

入力を受け取り、スクロール可能なseekToメソッドを使用keyupして特定のスライドに移動するボックスがあります。問題は、誰かがすばやく入力すると、スクロール可能なものが大きなキューになり、アニメーションが停止するまでに時間がかかることです。

私が望むのはkeyup、前のアニメーションが停止し (入力が空の場合を除く)、新しいアニメーションが開始することです。いろいろなところに入れてみましたが、うまくいきません.stop()

ここに私がやっていることと似たようなフィドルがあります: http://jsfiddle.net/QaMZH/

ボックスに数字を入れて (例: 1)、それを別の数字 (例: 2) に変更すると、スクロール可能なものがそのスライド番号にアニメーション化されますが、数字を変更すると、完了するまでに時間がかかるアニメーションの束がすぐにキューに入れられます。

4

1 に答える 1

1

I had the same problem, and after searching for more detailed documentation and fail, I just dug into the code.

It turns out that all you need to do is call this before .seekTo():

api.getItemWrap().stop(true, false);
api.seekTo($(this).val(), 1000);

where getItemWrap() returns the target jQuery element where the animation takes place.

See http://jsfiddle.net/QaMZH/4/ how the modified version works.

This works because .seekTo() method calls the jQuery .animation() method on the elements, and you can cancel jQuery animations any time with .stop().

于 2013-12-04T11:13:22.987 に答える