0

特定の条件に一致したら、スクロールのアニメーションを停止したい。

ここに私が持っている

var $box2 = $('.column'),
    Width = max_x,
    cursor = 0;
var Width = $("#column").width();
console.log(divWidth)


$("#right-button").click(function () {
    if (cursor != Width && Width >= divWidth) {
        $box2.animate({
            marginLeft: "-=100"
        }, "fast");

        cursor += 300;
    }
});

クリックに応じて、スクローラーを - 0r +300 にアニメーション化しています。そして、現在の幅が全体の幅よりも大きい、アニメーションを停止するなどの条件をここに書きたいと思います。

if で試しましcursor != totalWidth && totalWidth >= divWidth && this.width > totalWidthたが、機能しません。アニメーション中に現在の幅を見つける方法は? ここで何をすべきですか?

4

1 に答える 1