Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 鼠标滚轮延迟/增量求和功能非常灵活_Javascript_Jquery_Html - Fatal编程技术网

Javascript 鼠标滚轮延迟/增量求和功能非常灵活

Javascript 鼠标滚轮延迟/增量求和功能非常灵活,javascript,jquery,html,Javascript,Jquery,Html,我有一个带有多个全屏面板的网页。出于苦行僧的目的,我试图让用户必须滚动一定数量的轮子三角形,以便身体动画化到下一页。我不知道我在这里做错了什么: page = document.body.scrollTop; currentPage = 0; tick = 0; wheelBounds = 500; wheelTimeout = null; window.onmousewheel = function(e){ clearTimeout(wheelTimeout); docume

我有一个带有多个全屏面板的网页。出于苦行僧的目的,我试图让用户必须滚动一定数量的轮子三角形,以便身体动画化到下一页。我不知道我在这里做错了什么:

page = document.body.scrollTop;
currentPage = 0;
tick = 0;
wheelBounds = 500;
wheelTimeout = null;

window.onmousewheel = function(e){
    clearTimeout(wheelTimeout);
    document.body.scrollTop = page;
    tick += -e.wheelDelta;
    wheelTimeout = window.setTimeout(function(){
        tick = 0;
    },100);
    // document.body.scrollTop = window.innerHeight*(currentPage);
    $("html,body").animate({
        scrollTop: window.innerHeight*(currentPage)
    });
    if(tick > wheelBounds || tick <-wheelBounds){
        page = document.body.scrollTop;
        currentPage = tick > wheelBounds ? (currentPage+1): currentPage > 0 ?(currentPage-1): currentPage;
        tick = 0;
        console.log(currentPage);
    }
}

你能更好地解释出哪里出了问题吗?另外,您在哪个浏览器中执行此操作?不同浏览器之间的控制盘增量可能不同。它在卷轴的第一页和第二页之间以极快的速度返回。这是镀铬的