-1
jQuery({someValue: 0}).animate({someValue: 38}, {
duration: 1500, easing:'swing',
step: function() {
$('#grow1').text(Math.ceil(this.someValue));
}
});
我如何确保动画不会启动,直到用户滚动到特定的div?滚动触发脚本
jQuery({someValue: 0}).animate({someValue: 38}, {
duration: 1500, easing:'swing',
step: function() {
$('#grow1').text(Math.ceil(this.someValue));
}
});
我如何确保动画不会启动,直到用户滚动到特定的div?滚动触发脚本
您可以使用类似http://scrollmagic.io之类的东西。它允许您在页面中定义一些触发器,然后在用户触及这些触发器时执行回调(在这种情况下为动画)。看看这个例子:http://scrollmagic.io/examples/basic/custom_actions.html
希望这会帮助你