vaheqelyan / svelte-grid

A responsive, draggable and resizable grid layout, for Svelte.
https://svelte-grid.now.sh/
MIT License
948 stars 57 forks source link

Hidden Grid is destroying its items when fastStart = true #89

Open woothu opened 3 years ago

woothu commented 3 years ago

In the Grid component if fastStart prop is true the items are rendered only if internal xPerPx is truthy:

https://github.com/vaheqelyan/svelte-grid/blob/master/src/index.svelte#L8

In case when Grid component is hidden (Grid inside node with display:none) the items inside the grid are destroyed, which causes an unnecessary re-render of all items when the Grid display is restored. It is very taxing on performance in case of heavy Grid items and increases the http requests number.

For the hotfix I used fastStart = false, but please provide some kind of caching mechanism, to allow grid items caching with fastStart = true. Caching should be independent of fastStart in my opinion.

vaheqelyan commented 3 years ago

In case when Grid component is hidden (Grid inside node with display:none) the items inside the grid are destroyed, which causes an unnecessary re-render of all items when the Grid display is restored. It is very taxing on performance in case of heavy Grid items and increases the http requests number.

If you can demonstrate the issue, using https://svelte.dev/repl, please do. It will be more helpful for me to understand and help you. I really don't understand how the fastStart property is related to performance