3 ms·
Listen for changes? Or poll for changes? Wouldn't your way consume a lot of unnecessary CPU?
by ars 13y ago
Listen for changes? Or poll for changes?
Wouldn't your way consume a lot of unnecessary CPU?
- yuchi 13y agoNot 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.