Conversation
This PR adds the ability to drag tools out of the toolbar and onto the canvas.  ## Interaction notes A user should be able to interact with the toolbar items in a few ways: 1. Click on the item to select the tool / activate its `onSelect` (on touch start or pointer up). 2. Click and drag to create the shape, begin translating, and display the tool as active; then drop to create the shape and in the case of text and notes begin editing it 3. Click and drag and press Escape to cancel ## Implementation This is very rough and involves a lot of duplication. It's not entirely clear to me what the right API here is, so **I'd love to get some input** on what we could do to make things easier. Some open questions: 1. Should we abstract the "create on drag start" behavior, or provide better information (ie the current page position) as the parameters to that callback? What about behaviors like "select and start editing after drag end"? 2. Is it the right idea to move the pointer move event to the container, so that it occurs in front of the UI? ## Testing Since this technically occurs at the UI layer, we'd have to write e2e tests to verify that things are working the way we expect them to. ### Change type - [x] `improvement` ### Test plan 1. Drag tools from the toolbar onto the canvas. 1. Drag tools from the toolbar overflow menu onto the canvas. ### Release notes - Adds the ability to drag shapes from the toolbar onto the canvas. ### API changes - Adds `onDragFromToolbarToCreateShape`, `OnDragFromToolbarToCreateShapesOpts`, and `onDragStart` on `TldrawUiMenuItem` to facilitate dragging shapes out of a toolbar --------- Co-authored-by: Mitja Bezenšek <mitja.bezensek@gmail.com> Co-authored-by: alex <alex@dytry.ch> Co-authored-by: Mime Čuvalo <mimecuvalo@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.3)
Can you help keep this open source service alive? 💖 Please sponsor : )