/dev/log: rye
-
2024/01/06
-
is zoomable now
-
useGestureEventandnormalizeWheelwere 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,AutoCADfor 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:
-
wheelevent will pan beforeemitinfo to user state chart to handle -
holding
ctrl/altwill zoom and immediately return withoutemiting anything to user state chart to handle
-
-
-
-
what we tried:
-
handling event using
onWheelprovided bytldrawapi:-
not working as intended due to
editorinterceptwheel eventandpanbefore emitinginfodetails to us -

-
-
patching
Editor.ts:-
i tried inverting the logic of
ctrl/altby removing!before -
Of course not working due to inability to comprehend the magic inside
tldrawlol ๐
-
-
-
-
-
2023/11/17
-
tldrawarchitecture: loosely manual to navigate@tldrawcodebase-
tldrawis a whiteboard app built upon html and svg not canvas-
scaleandtranslateboth usecss transform: nocanvasmath here -
every
shapesare represent with acomponentand anindicatorusingsvgto draw the outline of its shape-
componentof the shape can be any kind of markup(jsx) e.gdiv,button, even aniframepoint 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
tldrawuse-
react๐ -
@tldraw/signia: primitive signal home grown bytldrawteam to build -
@tldraw/state: built upon@tldraw/sigina -
@tldraw/editor: core engine whichtldrawteam 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/editorand friends can do
-
-
what is
components,default components?-
a set of
componentslayer on top each other and render together to provide some functionality for the canvas-
ref:
canvas.tseditor.css -
canvassplit 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 defsfor other shapes to reference to (cursor shape too) -
canvas/z-index:200: whereshapes/z-index:300get rendered, and things that follow shapes likeselection background -
overlay/z-index:400: foremost layer that have components that you can interact withshapesbehind like-
Handles: to manipulate shapes, scale, squish, expand, rotate -
Selection Foreground: to highlight selected shaped, createhandlesto 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
toolslike astate chartwhere onetool statecan transition to another throughaction/event -

-
notable, necessary
tools:Selection,Zoom,Hand,Line,Stamp
-
-
shape: things that exist oncanvas-
internal itโs just a
JSON recordcarry some information of how to render itsshapeonto thecanvas -
tldrawhave some defaultshapesbut we can create our own usingShapeUtils -
notable, regularly uses
propertyofShapeUtils:-
props -
coordinates, rotation of
shapeoncanvas:x,y,rotation -
flags:hideRotateHandles,hideResizeHandles
-
-
-
-