Skip to content
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

Replace queueMicrotask with requestAnimationFrame #2969

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Jun 28, 2024

Description

This PR replaces queueMicrotask with requestAnimationFrame. Turns out that introducing useLayoutEffect (which was introduced in #2925) ended up in gestures being attached in wrong order in some cases.

This can be observed in #2963 (it is highly recommended to look into repro structure):

  1. 3 handlers from ZoomView where attached - they have correct tags
  2. Re-render happens, handlers' tags are now -1
  3. Pan from SVGMask is attached - all handlers marked as simultaneous have tag -1, therefore relations are not set up
  4. Handlers from 1. are attached again, so they get back their original tags

In this scenario, simultaneous handlers array in Pan in SVGMask was empty, effectively disabling this relation. Switching to requestAnimationFrame solves this problem.

Test plan

Verify that examples work as they used to (draggable, multitap, transformations)

Also tested on code from #2963 .

@m-bert m-bert merged commit 31a62e9 into main Jun 28, 2024
2 checks passed
@m-bert m-bert deleted the @mbert/replace-microtask-with-raf branch June 28, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants