-
Hi! I just recently started using LayerCake and it has really simplified my data visualisation work a lot. Thanks! Atm I am trying out using LayerCake + d3 force simulation + canvas. Is there is a good Canvas example with animations/transitions? Here is a REPL with my code. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I can see if I can take a look. I think the issue is that svelte isn't able to detect what is changing. I think you'll want to specify a draw function that re-reruns when something changes. So if the node variables are changing, then on tick, a function fires in your canvas renderer to draw things. A better model might be that instead of a edit: REPL with this implemented: https://svelte.dev/repl/9ef75645765243ba82253301a902024d?version=4.2.16 |
Beta Was this translation helpful? Give feedback.
-
@seblammers @mhkeller In the end I used a modified version of Matthias code. Anyways, maybe LayerCake could be a bit opinionated in how canvas animations can be implemented? Look at |
Beta Was this translation helpful? Give feedback.
@seblammers
Thanks! I've seen it and his code for a more complex solution: https://github.com/spiegelgraphics/nobel-laureates/tree/main
I was hoping to skip the registering/deregister/invalidate pattern.
@mhkeller
I tried your solution and it looks exactly like what I was hoping to achieve. Unfortunately it doesn't work if you have multiple components that update the context since this triggers some kind of reactivity loop in the functions that are dependent on the canvas context (the browser tab becomes totally unresponsive). Or maybe I did something wrong 😕 .
In the end I used a modified version of Matthias code.
Have a look in my REPL again (I forgot to fork before modifying 😢):
https:…