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

Execute dragging() once per frame #466

Merged
merged 1 commit into from
Oct 29, 2023
Merged

Execute dragging() once per frame #466

merged 1 commit into from
Oct 29, 2023

Conversation

WillH0lt
Copy link
Contributor

I was having an issue panning with two fingers. If I drag my fingers side by side (like riding inline skates) it pans as expected. But if I drag my fingers one in front of the other (like riding a skateboard) it would cause the screen to zoom, even though I'm not changing the distance between my fingers.

I figured out that the behavior is caused by calling "dragging()" multiple times in a single frame. The browser usually calls the pointer move event for each finger at around the same time. This means the position data for both fingers is only in-sync for the second call, the first call is using out-of-date pointer position for the other finger.

My solution is to add a _dragNeedsUpdate flag to ensure that dragging() would only be called once per frame.

Also I had to add tslib to the dev dependencies in order to run 'npm run build', so that's here as well.

@yomotsu
Copy link
Owner

yomotsu commented Oct 29, 2023

Thanks for your PR.
That makes sense and looks good to me.
merged!

@yomotsu yomotsu merged commit fab1d15 into yomotsu:dev Oct 29, 2023
yomotsu pushed a commit that referenced this pull request Oct 29, 2023
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