tldraw / tldraw

whiteboard / infinite canvas SDK
https://tldraw.dev
Other
35.6k stars 2.18k forks source link

[Feature]: Avoid an off-screen component being forced unmounted #4705

Open peilingjiang opened 2 weeks ago

peilingjiang commented 2 weeks ago

What's the feature?

ShapeUtil used to accept a canUnmount override, which is very helpful to avoid remounting costly components (including those that may make internet requests). Was it moved to some other places? Can we enable a way to avoid a shape being unmounted?

Where would you like this feature?

The developer package

Contact Details

No response

Code of Conduct

linear[bot] commented 2 weeks ago

TLD-2772 [Feature]: Avoid an off-screen component being forced unmounted

MitjaBezensek commented 2 weeks ago

We no longer unmount shapes, we just use display: none for the ones outside of the viewport. This helps with performance, but should avoid issues with remounting. Are you having any problems due to this?

peilingjiang commented 2 weeks ago

Thanks for the reply. I had some performance issues zooming in and out when there were a lot of components. Seems I need to look out for other approaches to optimize it.

Meanwhile, there is another problem. I sometimes render hanging widgets on the side of the shapes, as a child in the shape component, outside of the indicator area of the shape. While there are other ways to render them---like through components floating on top of the canvas, it's easier to manage them for each shape this way. However, as they are not part of the indicator, they will suddenly disappear as long as the shape is off-screen. I wonder if it's possible to disable the display: none behavior in this case? Thanks.