我想停止从动画中滚动一旦匹配特定条件。一旦它符合某些条件就停止动画 - 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片段。 –