gpt4 book ai didi

Javascript 滚动

转载 作者:太空宇宙 更新时间:2023-11-04 06:44:32 28 4
gpt4 key购买 nike

我试图做到这一点,以便当我向上或向下滚动页面时,它会运行不同的相应功能。我发现了一个类似的问题here但我已经尝试了他们的答案并且没有运气。
注意:此页面没有正常显示的滚动条。没有地方可以滚动。

body {
width: 100%;
height: 100vh;
}
<body>
<p>This is an example of the type of page I am talking about. It has a full page &lt;body&gt; which is what I have been trying to add the onscroll function to. I am open to other solutions though.
</body>

最佳答案

试试这个

window.addEventListener('wheel', function(e) {
if (e.deltaY < 0) {
console.log('scrolling up');
}
if (e.deltaY > 0) {
console.log('scrolling down');
}
});
body {
width: 100%;

}
<body>
<p>This is an example of the type of page I am talking about. It has a full page &lt;body&gt; which is what I have been trying to add the onscroll function to. I am open to other solutions though.
</body>

关于Javascript 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53423312/

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