From f1fbd4d596d7435a11ee93909b7bb4615a42e232 Mon Sep 17 00:00:00 2001 From: mircearoata Date: Wed, 15 May 2024 20:36:28 +0200 Subject: [PATCH] Replace custom virtual scroll with library for better resize performance --- frontend/package.json | 1 + frontend/pnpm-lock.yaml | 16 +++ .../src/lib/components/VirtualList.svelte | 112 ++++++------------ .../lib/components/mods-list/ModsList.svelte | 6 +- 4 files changed, 55 insertions(+), 80 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index f6b212cb..609735f9 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -21,6 +21,7 @@ "@graphql-typed-document-node/core": "^3.2.0", "@lukeed/uuid": "^2.0.1", "@tailwindcss/container-queries": "^0.1.1", + "@tanstack/svelte-virtual": "^3.5.0", "@urql/exchange-graphcache": "^6.4.0", "@urql/exchange-persisted": "^4.1.1", "@urql/svelte": "^4.0.4", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index cc0c6c88..5bb6d0d1 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -20,6 +20,9 @@ dependencies: '@tailwindcss/container-queries': specifier: ^0.1.1 version: 0.1.1(tailwindcss@3.3.6) + '@tanstack/svelte-virtual': + specifier: ^3.5.0 + version: 3.5.0(svelte@4.2.8) '@urql/exchange-graphcache': specifier: ^6.4.0 version: 6.4.0(graphql@16.8.1) @@ -2498,6 +2501,19 @@ packages: tailwindcss: 3.3.6 dev: false + /@tanstack/svelte-virtual@3.5.0(svelte@4.2.8): + resolution: {integrity: sha512-9fgqDeYV+5WBv/jar67Oy5Ddg3kbz43dPRHrIRk/dE9QinI4aCnWwM8VrjK7DDcw9zWAyj6BVC3miLMwyLNbAw==} + peerDependencies: + svelte: ^3.48.0 || ^4.0.0 + dependencies: + '@tanstack/virtual-core': 3.5.0 + svelte: 4.2.8 + dev: false + + /@tanstack/virtual-core@3.5.0: + resolution: {integrity: sha512-KnPRCkQTyqhanNC0K63GBG3wA8I+D1fQuVnAvcBF8f13akOKeQp1gSbu6f77zCxhEk727iV5oQnbHLYzHrECLg==} + dev: false + /@tsconfig/svelte@5.0.2: resolution: {integrity: sha512-BRbo1fOtyVbhfLyuCWw6wAWp+U8UQle+ZXu84MYYWzYSEB28dyfnRBIE99eoG+qdAC0po6L2ScIEivcT07UaMA==} dev: true diff --git a/frontend/src/lib/components/VirtualList.svelte b/frontend/src/lib/components/VirtualList.svelte index ec558891..2da089c2 100644 --- a/frontend/src/lib/components/VirtualList.svelte +++ b/frontend/src/lib/components/VirtualList.svelte @@ -1,100 +1,54 @@
- {#each visibleItems as item (item.index)} -
- Missing template -
- {/each} +
+ {#each vitems as row, idx (row.index)} +
+ Missing template +
+ {/each} +
diff --git a/frontend/src/lib/components/mods-list/ModsList.svelte b/frontend/src/lib/components/mods-list/ModsList.svelte index baf185f3..6a5fa790 100644 --- a/frontend/src/lib/components/mods-list/ModsList.svelte +++ b/frontend/src/lib/components/mods-list/ModsList.svelte @@ -193,7 +193,11 @@ {/if} {:else} - +