From dfa7428ba8690800419a3d757b8d1da4a07d0136 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 22 Feb 2025 15:36:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BD=93=E6=BB=9A=E5=8A=A8=E6=9D=A1?= =?UTF-8?q?=E5=AD=90=E5=85=83=E7=B4=A0=E5=8F=98=E6=8D=A2=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E6=9C=80=E5=A4=A7=E9=95=BF?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/render/components/scroll.tsx | 20 +++++++++++++++++--- src/module/render/ui/statusBar.tsx | 8 ++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/module/render/components/scroll.tsx b/src/module/render/components/scroll.tsx index 0f37338..85017fc 100644 --- a/src/module/render/components/scroll.tsx +++ b/src/module/render/components/scroll.tsx @@ -45,7 +45,7 @@ export interface ScrollProps { * 滚动到最下方(最右方)时的填充大小,如果默认的高度计算方式有误, * 那么可以调整此参数来修复错误 */ - padHeight?: number; + pad?: number; } type ScrollSlots = SlotsType<{ @@ -53,7 +53,7 @@ type ScrollSlots = SlotsType<{ }>; const scrollProps = { - props: ['hor', 'noscroll', 'loc', 'padHeight'] + props: ['hor', 'noscroll', 'loc', 'pad'] } satisfies SetupComponentOptions; /** 滚动条图示的最短长度 */ @@ -199,8 +199,22 @@ export const Scroll = defineComponent( */ const onTransform = (item: RenderItem) => { const rect = item.getBoundingRect(); + const pad = props.pad ?? 0; + if (direction.value === ScrollDirection.Horizontal) { + if (rect.right > maxLength - pad) { + maxLength = rect.right + pad; + updatePosition(); + } + } else { + if (rect.bottom > maxLength - pad) { + maxLength = rect.bottom + pad; + updatePosition(); + } + } getArea(item, rect); checkItem(item); + scroll.value?.update(); + content.value?.update(); }; /** @@ -256,7 +270,7 @@ export const Scroll = defineComponent( listenedChild.add(v); checkItem(v); }); - maxLength = max + (props.padHeight ?? 0); + maxLength = max + (props.pad ?? 0); updatePosition(); scroll.value?.update(); }; diff --git a/src/module/render/ui/statusBar.tsx b/src/module/render/ui/statusBar.tsx index 1768444..51f62fd 100644 --- a/src/module/render/ui/statusBar.tsx +++ b/src/module/render/ui/statusBar.tsx @@ -169,11 +169,11 @@ export const RightStatusBar = defineComponent>( return ( - + - - - + + + );