我有问题,我想要这样:
$(window).on('mousewheel', function(event) {
//prevent mousewheel in 1s
//do something, after 1s, enable mousewheel
}
或类似这样: 您在1秒内多次滚动滚轮,在事件鼠标滚轮运行1次时起作用。 有人帮我!
答案 0 :(得分:1)
您可以执行以下操作:
var mouseWheelEnabled = true;
function doSomethingWithMousewheel(event){
if(mouseWheelEnabled){
//... your code here
// set enabled = false;
mouseWheelEnabled = false;
setTimeout(function(){
mouseWheelEnabled = true;
}, 1000);
}
}
$(window).on('mousewheel', doSomethingWithMousewheel);
答案 1 :(得分:0)
var scrollstop = false;
$(window).on('mousewheel', function(event) {
if(!scrollstop) {
scrollstop = true;
setTimeout(() => { scrollstop = false; }, 1000);
}
}
像这样吗?
答案 2 :(得分:0)
var swiper = new Swiper(".swiper-container", {
slidesPerView: "auto",
freeMode: true,
loop: true,
loopedSlides: 8 // according to the codepen
mousewheel: {
releaseOnEdges: true,
},
});
pauseWheel是一个变量true,如果在最近1000毫秒内触发了mousewheel事件。