0
如果您在传递div ID“one”时查看此jsfiddle,然后在移动完整190px之前再次滚动,则动画将在您滚动时停止。即使再次滚动,动画仍然保持为190px,而当它返回-100px时,动画仍然保持原样。停止。动画重新计算。滚动位置
var $test = $(".test2");
$(window).scroll(function() {
if ($(this).scrollTop() > $('#one').position().top) {
$test.stop().animate({left: "190px"}, 1000);
} else {
$test.stop().animate({left: "-100px"}, 1000);
}
})
不幸的是无法工作。 – maxmitch