Reputation: 550
I am trying to make it so that when I scroll my page up or down it runs a different corresponding function. I found a similar question here but I have tried their answers and have had no luck.
NOTE: This page does not have a normally appearing scrollbar. There is nowhere to scroll to.
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 <body> which is what I have been trying to add the onscroll function to. I am open to other solutions though.
</body>
Upvotes: 0
Views: 54
Reputation: 3782
Try this
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 <body> which is what I have been trying to add the onscroll function to. I am open to other solutions though.
</body>
Upvotes: 1