HN2new | past | comments | ask | show | jobs | submitlogin

Listen for changes? Or poll for changes?

Wouldn't your way consume a lot of unnecessary CPU?



Not exactly poll. Use scroll events to start your polling; after the second time your loop function doesn't find a change in the scrollTop, stop requesting frames.

Even without this guard, with just the `old !== getScrollTop()` it doesn't eat so much CPU neither.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: