-
Notifications
You must be signed in to change notification settings - Fork 210
Consider marking event handler as 'passive' to make the page more responsive #143
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
We don't add event listeners on wheel, but we do on scroll which is probably what caused this. However, this should be resolved as of v4.0.0. What version are you using? |
I was using I have since then reverted back to the previous version I used before the upgrade, i.e. |
Hmm, interesting. With 4.1.0, can you use chrome dev tools to look at the event listeners added to the page (in the Elements tab). Can you find the one added by waypoint and see if it says |
Thanks for the detailed investigation. I agree that it doesn't seem that react-waypoint is the culprit here. It sounds like it might be worth following up with some of the other packages that you are using to see if they can enable the passive option. It might be worth pointing them at consolidated-events which is what react-waypoint uses for managing this sort of thing. |
Thanks @lencioni, by any chance you know how to view the event listeners added by I noticed the |
It looks like you have source maps, which should give you the actual filename of the module that added the event listener. I haven't verified but I believe that with react-waypoint v4 you should see an event listener added from the consolidated-events package, likely from the TargetEventHandlers.js module. |
Specifically, this is the line that adds the event listeners for react-waypoint: https://github.com/lencioni/consolidated-events/blob/d0ea74735de6a53a29e6273dcfa4a4d3ab0eb196/src/TargetEventHandlers.js#L44 |
Thanks for the tips @lencioni ! I've located the However, according to https://github.com/brigade/react-waypoint/blob/master/src/waypoint.jsx#L141 , do we also expect another |
Further investigation on the |
No, that |
Correct me if I'm wrong, so I think what you are trying to point out was by using |
Close, but not quite. The idea behind consolidated-events is to combine multiple event handlers for the same event type on the same node into a single event handler. So, if you add multiple scroll events to the same node, it should only add one. It will not consolidate different types of event handlers (e.g. scroll and resize) into a single one. That is not possible. Secondarily, it allows you to use options like the |
Thanks for the clarifications @lencioni , really learnt a lot today. For the original issue with |
Hi:
I was using Chrome version:
Version 55.0.2883.75 beta (64-bit)
with react-waypoint and noticed the following warning message when I scroll with the mouse wheel:I wonder if this warning would go away if we add the
wheel
event listener with the{ passive: true }
flag inreact-waypoint
?The text was updated successfully, but these errors were encountered: