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

fix: Disable three finger pinch zoom in penMode #4725

Merged
merged 14 commits into from
Feb 6, 2022

Conversation

zsviczian
Copy link
Collaborator

@vercel
Copy link

vercel bot commented Feb 6, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/excalidraw/excalidraw/Ezn4AtG6xLgbJ17B7JsHdHsYE7h6
✅ Preview: https://excalidraw-git-zsviczian-fix-penmode-pinchzoom-excalidraw.vercel.app

@zsviczian zsviczian changed the title disable pinch zoom for elementTypes fix: Disable pinch zoom in penMode for ["ellipse", "rectangle", "diamond", "line", "arrow", "freedraw"] Feb 6, 2022
@zsviczian zsviczian changed the title fix: Disable pinch zoom in penMode for ["ellipse", "rectangle", "diamond", "line", "arrow", "freedraw"] fix: Disable pinch zoom in penMode Feb 6, 2022
@zsviczian zsviczian changed the title fix: Disable pinch zoom in penMode fix: Disable pinch zoom in penMode for freedraw Feb 6, 2022
@zsviczian zsviczian changed the title fix: Disable pinch zoom in penMode for freedraw fix: Disable pinch zoom in penMode Feb 6, 2022
Comment on lines 1940 to 1942
if (this.state.penMode && isExcalidrawElement(this.state.elementType)) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just disable on gesture.pointers.size >= 2 (line 1936)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dwelle: returning from onGestureChange if gesture.pointers.size > 2 && penMode && isExcalidrawElement results in a smooth drawing experience. If I try really hard, I can produce unwanted zoom and jump, but even deliberately trying it is hard... I need to slide my hand onto the screen before starting to draw, to achieve the jump. This way two-finger pinch-zoom and panning both works even in penMode!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By my suggestion I meant that we already bail on gesture.events.size === 2 a line above, so I think we can just make the check into >= 2 and not check penMode or anything else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you don't want 3 finger pinch zoom, not even in "selection" mode?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll see, but right now it's not implemented anyway. And bear in mind that the gesturechange handler is for mac trackpad. Touchscreens are handled elsewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the change, but I can't test on a Mac touchpad.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on Mac and it works fine (at least there's no behavioral change from production).

@zsviczian zsviczian changed the title fix: Disable pinch zoom in penMode fix: Disable three finger pinch zoom in penMode (but allow two finger zoom) Feb 6, 2022
this.state.elementType === "freedraw" && this.state.penMode
? 1
: distance / gesture.initialDistance;
const scaleFactor = distance / gesture.initialDistance;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you revert his (in f5fc2eb) by mistake?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhm, judging from the PR title change, it was intentional. But allowing pinch-zooming in pen mode is causing issues while drawing again (for me, palm is regularly detected as a pinch zoom).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I removed it intentionally... it did not cause issues for me, but if it is causing issues for you, I am sure It will for many others as well. So sadly I'll put this back. Having pinch zoom during freedraw is very valuable. you can zoom in to work on small detail, and zoom out for bigger strokes. Needing to change tools breaks the flow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having pinch zoom during freedraw is very valuable. you can zoom in to work on small detail, and zoom out for bigger strokes. Needing to change tools breaks the flow.

I agree. I was thinking there might be some heuristic to detect with high accuracy whether you're actually pinching with two fingers, but that's for another PR.

@dwelle dwelle changed the title fix: Disable three finger pinch zoom in penMode (but allow two finger zoom) fix: Disable three finger pinch zoom in penMode Feb 6, 2022
@dwelle dwelle merged commit 98ea466 into master Feb 6, 2022
@dwelle dwelle deleted the zsviczian-fix-penMode-pinchzoom branch February 6, 2022 15:56
@jgonggrijp
Copy link

Both of you rock. I'll make sure to hit the funding options.

@dwelle
Copy link
Member

dwelle commented Feb 6, 2022

Thanks @jgonggrijp! ❤️

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

3 participants