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

lostPointerCapture event cancels pinch gestures #599

Merged
merged 2 commits into from
May 21, 2023
Merged

lostPointerCapture event cancels pinch gestures #599

merged 2 commits into from
May 21, 2023

Conversation

ds300
Copy link
Contributor

@ds300 ds300 commented May 16, 2023

Hello 👋🏼

At tldraw we use use-gesture for our canvas interactions. We recently noticed one situation where we use a long press on our canvas (the gesture target elem) to open a context menu. In iOS safari, this was firing a pointerdown event on the canvas and a pointerup event on the context menu. This left the PinchEngine in a broken state where it thought that the pointer was still down because it never received the pointerup event.

I noticed that you use the lostpointercapture event in the DragEngine to handle precisely this kind of situation, and it seems to work for the PinchEngine too. At least in our case.

I'd normally add tests for a PR like this, but I ran into problems with your test setup and it seems like a rabbit hole to figure out so I didn't add any tests yet. Please let me know if you'd like me to dig in and figure that out.

@changeset-bot
Copy link

changeset-bot bot commented May 16, 2023

🦋 Changeset detected

Latest commit: 70281d5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@use-gesture/core Patch
@use-gesture/react Patch
@use-gesture/vanilla Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 16, 2023

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 70281d5:

Sandbox Source
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration
pmndrs/use-gesture Configuration

@dbismut
Copy link
Collaborator

dbismut commented May 20, 2023

Hey @ds300 thanks a lot for the PR, I'm a huge fan of tldraw. I'll merge this tomorrow. Just curious if you ran into a similar issue with drag?

@dbismut
Copy link
Collaborator

dbismut commented May 21, 2023

@ds300 would you mind giving me access rights to the PR or running pnpm changeset and pass this as a patch change if you know how this works?

@ds300
Copy link
Contributor Author

ds300 commented May 21, 2023

@dbismut done!

And no we don't use the drag gesture so we haven't seen any issues there.

@dbismut dbismut merged commit 0dce221 into pmndrs:main May 21, 2023
@ds300 ds300 deleted the david/lost-pointer-capture-cancels-pinch-gestures branch May 21, 2023 14:10
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.

2 participants