lostPointerCapture event cancels pinch gestures #599
Merged
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.
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 apointerdown
event on the canvas and apointerup
event on the context menu. This left thePinchEngine
in a broken state where it thought that the pointer was still down because it never received thepointerup
event.I noticed that you use the
lostpointercapture
event in theDragEngine
to handle precisely this kind of situation, and it seems to work for thePinchEngine
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.