p0o / react-is-scrolling

Simply detect if users are scrolling in your components in a declarative API
https://p0o.github.io/react-is-scrolling/
MIT License
17 stars 9 forks source link

No reactive update #2

Open mo-ib opened 6 years ago

mo-ib commented 6 years ago

If I scroll up and down fast in a fluid motion, it still just says "UP" or "DOWN" and doesn't update until I stop moving. This only detects the initial direction of a series of scroll gestures.

AntonVoltchok commented 6 years ago

@p0o @threecity I'm not using this package but I had to debug the UP DOWN scrolling issue recently and it's because debounce is used instead of throttle, if you think about the way debounce works, it's logical it's not going to be accurate for direction detection. Switching to throttle at 16ms, making it 60 frames per second, solved my issues (you can up the time if you are doing very heavy calculation).

@p0o I would suggest either keeping debounce as is, and removing UP and DOWN from functionality of this library, or switching to throttle and keeping UP and DOWN , that way it's always accurate.

p0o commented 6 years ago

@AntonVoltchok Thanks, using throttle instead of debounce makes sense. Would you like to submit a PR yourself?

AntonVoltchok commented 6 years ago

@p0o hey sorry for the delayed response been swamped recently, but will have some free time soon so I can do a PR to switch it over.