1

$(window).scroll() lets you detect scroll events.

However, a single scroll triggers it many times.

How can I detect a literal scroll event; ie corresponding to a single swipe or mouse scroll?

Using a time threshold isn't ideal, because if you scroll hard enough, it can trigger up to a couple seconds' worth of scrolling.

3
  • 1
    You can't, all you can do is debounce it or count the scrolled amount Commented Jul 21, 2017 at 20:45
  • Watch the pointer events developer.mozilla.org/en-US/docs/Web/API/PointerEvent Commented Jul 21, 2017 at 20:52
  • The right keyword for your question is scroll delta, good luck. Commented Jul 21, 2017 at 23:38

1 Answer 1

2

There aren't native events to detect when scrolling starts and stops, but you can achieve it through a plugin like this: https://github.com/ssorallen/jquery-scrollstop

It provides two events, scrollstart and scrollstop.

$(window)
  .on("scrollstart", function() {

  })
  .on("scrollstop", function() {

  });

It basically fires the scrollstart event after the first scroll then fires the scrollstop event after 250ms of no other scroll events. The time is adjustable.

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

Comments

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.