edemaine / cocreate

Cocreate Shared Whiteboard/Drawing
MIT License
209 stars 27 forks source link

Toggle for touch only pan/select #62

Closed ccai1 closed 3 years ago

ccai1 commented 3 years ago

This is an attempt at implementing #39 to allow disabling or customizing for touch mode, especially for tablets. This change adds a button (below eraser) that toggles between restricting touch to only pan/select and allowing touch for all functions, including drawing. The default mode is touch only pan/select.

To help create a toggle, I tried to follow the code for "Toggle grid/graph paper," so I'm not sure if some lines are extraneous 🙂 (The button toggles the truth value of variable currentTouch and drawing events for pen, line, ellipse, rect, etc. are stopped if currentTouch equals false and pointerType equals touch). This feature was tested on a non-touch-enabled computer and a tablet with stylus.

Some concerns:

edemaine commented 3 years ago

@ccai1 Thanks again for making this happen! I did some testing and it does seem like pretty good behavior, at least as a first step. I also changed the default behavior to allow touch input, which seems pretty important.

I did a bunch of revisions/cleanup to this PR (directly on your branch). Please have a look, both to learn about stylistic improvements/consistency and to see that you agree e.g. with the new help text. Then I'll merge.

ccai1 commented 3 years ago

@edemaine Looks good to me! I think the description, position, and icon of the toggle makes its purpose clearer to the user now. Thanks for the revisions.