-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Support passive scroll listeners #398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Browser support:
|
Hey @romulof! Thanks for the proposal. I'm definitely interested, if you'd be willing to put together a POC. I have some initial concerns but we should test it out and see. My concerns are:
|
On standard scroll listeners the browser has to wait for the callback chain to finish before continuing the scroll, because someone might call One thing that is not obvious is the part of the life cycle when react calls your I'm using these passive listeners in my current app and so far, so good. No problems with setState batching, but I'll read a little more on how React handles this and write down that POC. And I didn't understand where requestAnimationFrame might be applied. PS: Congrats for your library, it's very well written. |
Right, right. I understand the appeal of passive listeners and I think this could be a big performance win. I'd love to give it a try. 😁 I'm encouraged to hear that you're already using them in your app. That seems even more promising.
May be unnecessary! 😄 Let's do it. I'd love to review a PR if you'd like to put one together. And thank you! Much appreciated. 🙇 |
Okay. I've got a branch locally where I've experimented with this a bit. Surprisingly, I don't see any improvements for my test harnesses (eg It's gotten late. I'll continue exploring this. Feel free to jump in and experiment with me if you'd like!
Edit: The above changes have been merged to Your above options-support detection code looks fine. There's also the |
For the moment I am going to close this issue because I have not seen any positive performance impact. (I've actually seen some negative impact but I think that could be negated by batching my own I'll still keep the idea around. I think it might be worth revisiting in a couple of months. Of course, if you find the time to experiment and find any different results than I did- let me know. |
By the way, I pushed my work-in-progress branch if you have any interest in checking it out: It has very minimal changes: |
Make
Grid
use passive scroll listeners (when available) for huge performance improvements.Reference: https://developers.google.com/web/updates/2016/06/passive-event-listeners
Since React does not support passive event listeners (yet: facebook/react#6436), we have first to test for browser support using the following module (coded in es7 + flowtype):
Then instead of attaching using react's
onScroll
component prop, get the elements ref and add the event handler directly (or using the helper function inListernerOptions
).I can submit the PR if there are no objections.
The text was updated successfully, but these errors were encountered: