From a8a24605d4d993b3498c0f12f55d274ca933582e Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Sun, 8 Mar 2026 12:51:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E8=A1=A8?= =?UTF-8?q?=E5=A4=B4=E6=BB=9A=E5=8A=A8=E7=9B=91=E5=90=AC=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=8A=82=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/MobileFundTable.jsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/MobileFundTable.jsx b/app/components/MobileFundTable.jsx index be2e95c..aeae01e 100644 --- a/app/components/MobileFundTable.jsx +++ b/app/components/MobileFundTable.jsx @@ -23,6 +23,7 @@ import { useSortable, } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; +import { throttle } from 'lodash'; import FitText from './FitText'; import MobileSettingModal from './MobileSettingModal'; import { ExitIcon, SettingsIcon, StarIcon } from './Icons'; @@ -308,7 +309,7 @@ export default function MobileFundTable({ return isSummaryStuck ? stickyTop + stickySummaryWrapper.offsetHeight : stickyTop; }; - const handleVerticalScroll = () => { + const updateVerticalState = () => { const nextStickyTop = getEffectiveStickyTop(); setEffectiveStickyTop((prev) => (prev === nextStickyTop ? prev : nextStickyTop)); @@ -321,12 +322,15 @@ export default function MobileFundTable({ setShowPortalHeader(tableRect.top <= nextStickyTop); }; - handleVerticalScroll(); - window.addEventListener('scroll', handleVerticalScroll, { passive: true }); - window.addEventListener('resize', handleVerticalScroll, { passive: true }); + const throttledVerticalUpdate = throttle(updateVerticalState, 50, { leading: true, trailing: true }); + + updateVerticalState(); + window.addEventListener('scroll', throttledVerticalUpdate, { passive: true }); + window.addEventListener('resize', throttledVerticalUpdate, { passive: true }); return () => { - window.removeEventListener('scroll', handleVerticalScroll); - window.removeEventListener('resize', handleVerticalScroll); + window.removeEventListener('scroll', throttledVerticalUpdate); + window.removeEventListener('resize', throttledVerticalUpdate); + throttledVerticalUpdate.cancel(); }; }, [stickyTop]);