From 6a6301012f8c94b48c7954c279d1a7f4ac88f329 Mon Sep 17 00:00:00 2001 From: Yourz Date: Mon, 15 Dec 2025 18:58:01 +0800 Subject: [PATCH] refactor: use calculateScrollPercentage utility function Apply suggestion from coderabbitai bot --- src/components/common/TreeExplorer.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/common/TreeExplorer.vue b/src/components/common/TreeExplorer.vue index 043a373273..afb87e2a29 100644 --- a/src/components/common/TreeExplorer.vue +++ b/src/components/common/TreeExplorer.vue @@ -66,6 +66,7 @@ import { combineTrees, findNodeByKey } from '@/utils/treeUtil' import type { WindowRange } from '@/utils/virtualListUtils' import { applyWindow as applyWindowUtil, + calculateScrollPercentage, calculateSpacerHeights, createInitialWindowRange, shiftWindowBackward as shiftWindowBackwardUtil, @@ -201,12 +202,13 @@ const handleTreeScroll = useThrottleFn(() => { } const { topTotal, bottomTotal } = getTotalSpacerHeights() - const realContentHeight = scrollHeight - topTotal - bottomTotal - const adjustedScrollTop = Math.max(0, scrollTop - topTotal) - const scrollPercentage = - realContentHeight > 0 - ? (adjustedScrollTop + clientHeight) / realContentHeight - : 1 + const scrollPercentage = calculateScrollPercentage( + scrollTop, + scrollHeight, + clientHeight, + topTotal, + bottomTotal + ) // When scrolling near bottom (70%), shift window forward if (scrollPercentage > 0.7) {