tldraw / tldraw-v1

A tiny little drawing app. This is the original 2021-2022 version, released under MIT.
https://old.tldraw.com
MIT License
64 stars 35 forks source link

[bug] Unable to scroll a component with trackpad / wheel #98

Closed brianfoody closed 10 months ago

brianfoody commented 2 years ago

I am trying to create a custom component where I can scroll the inner content when editing.

Unfortunately I can only scroll with the up / down arrows and the wheel event just gets captured by the canvas, panning the camera.

I am using the core-example-advanced and added a "ScrollBox" shape using the gist code below;

https://gist.github.com/brianfoody/86060ad9dc1132c4a366e80dcbd25f1f

i-am-the-slime commented 1 year ago

Same problem here. Any luck @brianfoody ?

Edit: Got a workaround working (I think that's what was meant in tldraw/tldraw-v1#520). It modifies the element's scrollTop value according to the wheel event's deltaY value.

{ onWheel: handler deltaY $ traverse_ \dY -> do
              elOrNot <- getElementFromRef containerRef
              for_ elOrNot (modifyScrollTop (_ + dY))
}