the-pudding / sleep-training

MIT License
0 stars 0 forks source link

Disable re-rendering of force simulation if renderedData values do not change #3

Closed tomvaillant closed 1 month ago

tomvaillant commented 2 months ago

I'm currently running the step logic in Index.svelte, calling a specific function containing this logic as a prop in the corresponding Section component lower down.

I'd like to avoid the force simulation re-rendering and re-positioning circles if the renderedData values do not change.

matthewfdaniels commented 2 months ago

the reason why it's re-rendering is because this statement will re-run every time a variable within it changes

image

So since step is changing, it's re-running stepHandler and generating a new array for newValues that's identical to the one before it.

we can probably debug this later, but my gut is that you pre-render/calculate everything at the start and then store those positions somewhere, passing them to the components as neccessary.

tomvaillant commented 2 months ago

This sounds like a larger structural change, happy to wait until later to look into it!