Jquery 滚动时防止鼠标输入功能

Jquery 滚动时防止鼠标输入功能,jquery,scroll,mouseenter,Jquery,Scroll,Mouseenter,当用户在jQuery中滚动时,我试图阻止鼠标指针功能发生,但无法理解,有什么建议吗 代码: 您可以按如下方式实现它: window.isScrolling = false; $(window).scroll(function() { window.isScrolling = true; clearTimeout($.data(this, "scrollTimer")); $.data(this, "scrollTimer", setTimeout(function() {

当用户在jQuery中滚动时,我试图阻止鼠标指针功能发生,但无法理解,有什么建议吗

代码:


您可以按如下方式实现它:

window.isScrolling = false;
$(window).scroll(function() {
    window.isScrolling = true;
    clearTimeout($.data(this, "scrollTimer"));
    $.data(this, "scrollTimer", setTimeout(function() {
        // If the window didn't scroll for 250ms
        window.isScrolling = false;
    }, 250));
});
然后按如下方式更改代码:

$(".li").mouseenter(function(){

// Prevent executing when the user is scrolling
if (window.isScrolling) return;

$(this).children(".work_name").toggleClass("open", 400);

$('.li').mouseleave(function(){
  $(this).children(".work_name").removeClass("open", 400);
});

});

您可以按如下方式实现它:

window.isScrolling = false;
$(window).scroll(function() {
    window.isScrolling = true;
    clearTimeout($.data(this, "scrollTimer"));
    $.data(this, "scrollTimer", setTimeout(function() {
        // If the window didn't scroll for 250ms
        window.isScrolling = false;
    }, 250));
});
然后按如下方式更改代码:

$(".li").mouseenter(function(){

// Prevent executing when the user is scrolling
if (window.isScrolling) return;

$(this).children(".work_name").toggleClass("open", 400);

$('.li').mouseleave(function(){
  $(this).children(".work_name").removeClass("open", 400);
});

});