0

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 &lt;body&gt; which is what I have been trying to add the onscroll function to. I am open to other solutions though.
</body>

1 Answer 1

1

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 &lt;body&gt; which is what I have been trying to add the onscroll function to. I am open to other solutions though.
</body>

Sign up to request clarification or add additional context in comments.

1 Comment

No luck. The page I am trying to do this with does not have anywhere to scroll to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.