gpt4 book ai didi

javascript - 鼠标滚轮后 1 秒阻止鼠标滚轮

转载 作者:行者123 更新时间:2023-12-01 00:59:52 26 4
gpt4 key购买 nike

我有一个问题,我想要这样:

$(window).on('mousewheel', function(event) {
//prevent mousewheel in 1s
//do something, after 1s, enable mousewheel
}

或者像这样:您在 1 秒内滚动滚轮多次,如果鼠标滚轮运行 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);

关于javascript - 鼠标滚轮后 1 秒阻止鼠标滚轮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56182138/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com