From f9c1a70b8f5b7f001b33bd4b821b5004b0e1c361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Tue, 26 Aug 2025 00:18:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=A9=E7=95=A5=E5=9B=BE?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=20=E8=87=AA=E5=8A=A8=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E5=81=8F=E5=B7=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/pages/work-flow/thumbnail-grid.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/components/pages/work-flow/thumbnail-grid.tsx b/components/pages/work-flow/thumbnail-grid.tsx index 3e2d1fd..b089323 100644 --- a/components/pages/work-flow/thumbnail-grid.tsx +++ b/components/pages/work-flow/thumbnail-grid.tsx @@ -30,13 +30,19 @@ export function ThumbnailGrid({ useEffect(() => { if (thumbnailsRef.current) { const container = thumbnailsRef.current; - const thumbnailWidth = container.offsetWidth / 4; // 每个缩略图宽度(包含间距) - const scrollPosition = currentSketchIndex * thumbnailWidth; + const thumbnails = container.children; + + if (currentSketchIndex >= 0 && currentSketchIndex < thumbnails.length) { + const thumbnail = thumbnails[currentSketchIndex] as HTMLElement; + const containerLeft = container.getBoundingClientRect().left; + const thumbnailLeft = thumbnail.getBoundingClientRect().left; + const scrollPosition = container.scrollLeft + (thumbnailLeft - containerLeft); - container.scrollTo({ - left: scrollPosition, - behavior: 'smooth' - }); + container.scrollTo({ + left: scrollPosition, + behavior: 'smooth' + }); + } } }, [currentSketchIndex]);