Fix movementX/Y polyfill with capture events#19672
Merged
gaearon merged 2 commits intofacebook:masterfrom Aug 21, 2020
Merged
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f976c48:
|
lunaruan
approved these changes
Aug 21, 2020
IDisposable
reviewed
Oct 28, 2020
| lastMovementX = 0; | ||
| lastMovementY = 0; | ||
| } | ||
| lastMouseEvent = event; |
There was a problem hiding this comment.
Won't this GC root the event? This seems like a leak.
Collaborator
Author
There was a problem hiding this comment.
It will root only one (the very last) mouse event, and only on IE11, so this should not be an issue.
This was referenced Mar 9, 2021
This was referenced Mar 15, 2021
Merged
koto
pushed a commit
to koto/react
that referenced
this pull request
Jun 15, 2021
* Fix movementX/Y polyfill with capture events * Remove unnecesary call for better inlining
This was referenced Oct 1, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a blocker I need to resolve for #19648.
Our
movementX/Ypolyfill is currently broken with the modern event system if you use a capture event. This is because it diffs thescreenX/Ywith the last event's values, but now we have two synthetic events per one native event (due to capture and bubble phase). So we create an event in the capture phase, set itsmovementX/Y, and then we create another object in the bubble phase, and itsmovementX/Yis calculated to be0(because it is diffed with the event we just created earlier).To fix this, I am pulling this logic out in one place and update both
movementXandmovementYvalues together and only if the native event has changed. This means we retain one last mouse event at a time (when the polyfill is used, which is IE11-only). Seems ok.Test Plan
Added a test that previously failed.
I also manually tested by forcing the polyfill to always be used and running it with this fixture:
Clicking and moving works as expected (no violations). There is a calculation bug every time after we move cursor outside the screen and bring it back, but this bug existed in 16 too, and I don't think it's worth fixing. (We'll remove the polyfill eventually anyway).