From 78184544cf360df76fb797710c8d4c9fdbc6b6d1 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Tue, 12 May 2026 13:50:03 +0800 Subject: [PATCH] perf(grid): optimize virtual scroll to reduce white flash during fast scrolling Add buffer, skip-hover, will-change, and CSS contain properties to all RecycleScroller instances (DataGrid, ConnectionTree, ObjectBrowser, RedisKeyBrowser). Disable pointer-events during scroll in DataGrid to reduce repaint overhead. --- src/components/grid/DataGrid.vue | 26 ++++++++++++++++++++++- src/components/objects/ObjectBrowser.vue | 20 ++++++++++++++++- src/components/redis/RedisKeyBrowser.vue | 21 +++++++++++++++++- src/components/sidebar/ConnectionTree.vue | 14 +++++++++++- src/composables/useFlatTree.ts | 2 +- 5 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue index 99f92a989..043d444ad 100644 --- a/src/components/grid/DataGrid.vue +++ b/src/components/grid/DataGrid.vue @@ -755,6 +755,17 @@ function syncHeaderScroll(e: Event) { } } +let scrollingTimer = 0; +const isScrolling = ref(false); +function onScrollerScroll(e: Event) { + syncHeaderScroll(e); + if (!isScrolling.value) isScrolling.value = true; + clearTimeout(scrollingTimer); + scrollingTimer = window.setTimeout(() => { + isScrolling.value = false; + }, 120); +} + initColumnWidths(); watch(() => visibleColumns.value.length, initColumnWidths); watch( @@ -2134,10 +2145,13 @@ defineExpose({ v-else ref="scrollerRef" class="data-grid-scroller flex-1 overflow-x-auto overscroll-none" + :class="{ 'is-scrolling': isScrolling }" :items="displayItems" :item-size="26" + :buffer="600" + :skip-hover="true" key-field="id" - @scroll="syncHeaderScroll" + @scroll="onScrollerScroll" > + + diff --git a/src/composables/useFlatTree.ts b/src/composables/useFlatTree.ts index 77d91e8bf..47abdcc0a 100644 --- a/src/composables/useFlatTree.ts +++ b/src/composables/useFlatTree.ts @@ -1,7 +1,7 @@ import type { TreeNode, TreeNodeType } from "@/types/database"; export const SIDEBAR_TREE_ROW_HEIGHT = 28; -export const SIDEBAR_TREE_SCROLL_BUFFER = SIDEBAR_TREE_ROW_HEIGHT * 48; +export const SIDEBAR_TREE_SCROLL_BUFFER = 600; export const SIDEBAR_TREE_PRERENDER_COUNT = 48; export interface FlatTreeNode {