我正在尝试达到像这里这样的效果。无论用户尝试滚动多少,我都想在每次滚动滚轮时执行一个操作。我将如何计算用户尝试滚动的次数?我一直在玩$(window).on('scroll'...
。谢谢
问问题
1184 次
2 回答
0
你的意思是这样的:
(function() {
var scroll = 0;
$(document).on('mousewheel DOMMouseScroll', function(event) {
scroll++;
console.log(event);
});
$('#click').on('click', function() {
alert(scroll);
});
})();
<button id="click">Show me</button>
(你显然可以把你自己的代码代替scroll++;
)
于 2013-09-11T21:54:24.350 回答
0
原来我真正需要的是找到滚动停止的时间。在这里得到解决方案。
var scrolls = 0;
$(window).scroll(function(){
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
pos++;
}, 50));
});
谢谢
于 2013-09-11T22:07:43.030 回答