tldraw/packages/tlschema/src
Steve Ruiz 7d699a749f
[improvements] arrows x enclosing shapes x precision. (#2265)
This PR makes several improvements to the behavior of arrows as they
relate to precision and container relationships.

- an arrow's terminals are always "true" and are never snapped to { x:
.5, y: .5 } as they were previously when not precise
- instead, a new `isPrecise` boolean is added to the arrow terminal
- when an arrow terminal renders "imprecisely" it will be placed to the
center of the bound shape
- when an arrow terminal renders "precisely" it will be placed at the
normalized location within the bound shape

![Kapture 2023-11-29 at 23 12
12](https://github.com/tldraw/tldraw/assets/23072548/e94e1594-75fa-4c94-86f3-7d911bf25f7f)

The logic now is...
- if the user has indicated precision by "pausing" while drawing the
arrow, it will be precise
- otherwise...
- if both of an arrow's terminals are bound to the same shape, both will
be precise
- if a terminal is bound to a shape that contains the shape that its
opposite terminal is bound to, it will be precise
- if a terminal is bound to a shape that contains the shape that its
opposite terminal is bound to, it will be precise
- or else it will be imprecise

If the spatial relationships change, the precision may change as well.

Fixes https://github.com/tldraw/tldraw/issues/2204

Note: a previous version of this PR was based around ancestry but that's
not actually important.

### Change Type

- [x] `minor` — New feature

### Test Plan

1. Draw an arrow between a frame and its descendant
2. Draw an arrow inside of a shape to another shape contained within the
bounds of the big shape
3. Vis versa
4. Vis versa

- [x] Unit Tests

### Release Notes

- Improves the logic about when to draw "precise" arrows between the
center of bound shapes.
2023-12-01 21:34:12 +00:00
..
assets [feature] add meta property to records (#1627) 2023-06-28 14:24:05 +00:00
misc [feature] multi-scribbles (#2125) 2023-10-29 14:37:36 +00:00
records [feature] multi-scribbles (#2125) 2023-10-29 14:37:36 +00:00
shapes [improvements] arrows x enclosing shapes x precision. (#2265) 2023-12-01 21:34:12 +00:00
styles [fix] broken docs link (#2062) 2023-10-10 13:23:49 +00:00
translations tlschema cleanup (#1509) 2023-06-03 20:46:53 +00:00
createPresenceStateDerivation.ts Replace Atom.value with Atom.get() (#2189) 2023-11-13 11:51:22 +00:00
createTLSchema.ts [feature] add meta property to records (#1627) 2023-06-28 14:24:05 +00:00
index.ts Remove fixup script (#2041) 2023-10-09 10:23:01 +00:00
migrations.test.ts [improvements] arrows x enclosing shapes x precision. (#2265) 2023-12-01 21:34:12 +00:00
store-migrations.ts [improvement] store snapshot types (#1657) 2023-06-27 12:25:55 +00:00
TLStore.ts Replace Atom.value with Atom.get() (#2189) 2023-11-13 11:51:22 +00:00
util-types.ts hoist opacity out of props (#1526) 2023-06-06 16:15:12 +00:00