eclipse-sirius / sirius-web

Sirius Web: open-source low-code platform to define custom web applications supporting your specific visual languages
https://eclipse.dev/sirius/sirius-web.html
Eclipse Public License 2.0
79 stars 52 forks source link

Improve performance of diagram viewport change #4206

Open AresEkb opened 3 hours ago

AresEkb commented 3 hours ago

Screenshots

No

Steps to reproduce

Drag any diagram to change its viewport. You can try to do it fast, in different directions.

Expected behavior

The diagram viewport is changed without any lags.

Actual behavior

Diagram drag is very laggy.

AresEkb commented 3 hours ago

Here is the fix https://github.com/eclipse-sirius/sirius-web/pull/4207

The problem is that <DiagramPanel> calls useArrangeAll() that calls useViewport(). When you drag a diagram, a viewport is changed, so useViewport() hook is updated, so useArrangeAll() is updated and so <DiagramPanel> is re-rendered. It can be re-rendered hundreds times during drag

I added a new hook useViewportZoom() that updated when zoom is changed. It's not updated on diagram drag