我想停止從動畫中滾動一旦匹配特定條件。一旦它符合某些條件就停止動畫 - jquery
這裏我有
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
,但無法正常工作。如何在動畫時查找當前寬度?我應該在這裏做什麼?
請發表您的代碼操縱的HTML片段。 –