Closed csenio closed 2 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/tldraw/core/BhmjD86A85Mh9ENkjZRp1QtGoZE9
✅ Preview: https://core-git-fork-jescowuester-feature-global-panning-tldraw.vercel.app
🔍 Inspect: https://vercel.com/tldraw/tldraw/61A2CtdXnqXRwmLE19Q4dYTXBaen
✅ Preview: https://tldraw-git-fork-jescowuester-feature-global-panning-tldraw.vercel.app
Should be done. Should I write tests for this somewhere?
I like it! The only place where I was able to break it was inside of an active text field: I could hold space and click and drag at the same time to pan while editing, though this is an admittedly weird interaction. This is mostly due to the lack of an "editing" state, which has been on the todo list for a while, so we'll fix it when we fix that.
Also able to pan while the context menu is open. Again, kind of a weird interaction so I'll let it go for the moment.
I think I found a good solution here, pushing some changes and tests.
Want to test this out @jescowuester?
I'm using the term "force panning" for panning while spacebar or middle mouse wheel is pressed.
Force panning now works regardless of any tool state. You can, for example, start resizing a shape, press spacebar and move the camera, then continue resizing the shape. Same for dragging, etc. I think this is ultimately what we're after with this kind of gesture!
@steveruizok I like it in theory, but I think this approach means we will have to handle a lot more edge cases. Here are 2 I just found:
We could probably disable all interactions while force dragging and then select a couple of desirable ones (like resizing a shape) to selectively enable. Not sure if it's worth the extra trouble though (I personally just let go of the shape when I want to pan my camera)
Great catches!
Merged! Thanks again @jescowuester .
@steveruizok don't think Prevent default on tool buttons keydown if forcePanning
worked, still having that same flicker
I can't reproduce it here, but I'll take another look!
closes tldraw/tldraw-v1#318