/dev/log: rye
-
2024/01/06
-
is zoomable now
-
useGestureEvent
andnormalizeWheel
were the missing pieces -
learned how to make a patch with
pnpm
-
-
2023/12/02
-
problem with scrolling with mouse in
tldraw
-
what we need: scroll to zoom like
cad
-
we want to mimic the user interaction of existing tools, such as
Autodesk's Revit
,AutoCAD
for ease of transition to our product. -
these tools scrolling the wheel means zooming instead of scrolling/panning.
-
relevant issues: #1344
-
-
what we knew:
-
currently in
tldraw
: the pinch, wheel and pointer get special treatment from tldraw event (i think)-
these kind of event all related to zooming and such
-
in wheel:
-
wheel
event will pan beforeemit
info to user state chart to handle -
holding
ctrl/alt
will zoom and immediately return withoutemit
ing anything to user state chart to handle
-
-
-
-
what we tried:
-
handling event using
onWheel
provided bytldraw
api:-
not working as intended due to
editor
interceptwheel event
andpan
before emitinginfo
details to us
-
-
patching
Editor.ts
:-
i tried inverting the logic of
ctrl/alt
by removing!
before -
Of course not working due to inability to comprehend the magic inside
tldraw
lol ๐
-
-
-
-
-
2023/11/17
-
tldraw
architecture: loosely manual to navigate@tldraw
codebase-
tldraw
is a whiteboard app built upon html and svg not canvas-
scale
andtranslate
both usecss transform
: nocanvas
math here -
every
shapes
are represent with acomponent
and anindicator
usingsvg
to draw the outline of its shape-
component
of the shape can be any kind of markup(jsx) e.gdiv
,button
, even aniframe
point to another site or another html -
svg is there to serialize, to indicate component
-
readmore: https://canary.tldraw.dev/docs/shapes#The-shape-object
-
-
-
technical stack aka stuff
tldraw
use-
react
๐ -
@tldraw/signia
: primitive signal home grown bytldraw
team to build -
@tldraw/state
: built upon@tldraw/sigina
-
@tldraw/editor
: core engine whichtldraw
team nicely split out for normie like me to poke around, and underlying of@tldraw/tldraw
-
this package purpose is for builder (like me and you) to build our own
tldraw
-
-
@tldraw/tldraw
: https://tldraw.com app, act as a demo showcasing capabilities of what@tldraw/editor
and friends can do
-
-
what is
components
,default components
?-
a set of
components
layer on top each other and render together to provide some functionality for the canvas-
ref:
canvas.ts
editor.css
-
canvas
split into 3 layers:background
,camera/overlay part of the canvas
,canvas
-
background
/z-index:100
: have background component, grid line, and ui debug log,svg defs
for other shapes to reference to (cursor shape too) -
canvas
/z-index:200
: whereshapes
/z-index:300
get rendered, and things that follow shapes likeselection background
-
overlay
/z-index:400
: foremost layer that have components that you can interact withshapes
behind like-
Handles
: to manipulate shapes, scale, squish, expand, rotate -
Selection Foreground
: to highlight selected shaped, createhandles
to manipulate
-
-
-
-
notable, necessary
components
:Background
,SelectionForeground
,Handles
,OnTheCanvas
,PositionOnCanvas
,
-
-
tools
: set of tools to interact with canvas, to create new shape, move around, select stuff, etcโฆ-
ref: canary docs
-
think about
tools
like astate chart
where onetool state
can transition to another throughaction/event
-
notable, necessary
tools
:Selection
,Zoom
,Hand
,Line
,Stamp
-
-
shape
: things that exist oncanvas
-
internal itโs just a
JSON record
carry some information of how to render itsshape
onto thecanvas
-
tldraw
have some defaultshapes
but we can create our own usingShapeUtils
-
notable, regularly uses
property
ofShapeUtils
:-
props
-
coordinates, rotation of
shape
oncanvas
:x
,y
,rotation
-
flags
:hideRotateHandles
,hideResizeHandles
-
-
-
-