From fc1c108e600c73f0daadc1afd0701db6bf192a7f Mon Sep 17 00:00:00 2001 From: wanjinping Date: Tue, 5 Nov 2024 16:04:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(scrollbar):=20=E4=BF=AE=E6=94=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#3019)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/scrollbar/src/Scrollbar.tsx | 7 ++++--- packages/ui/scrollbar/src/types.ts | 14 ++++++++++++++ packages/ui/scrollbar/stories/fixed.stories.tsx | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/ui/scrollbar/src/Scrollbar.tsx b/packages/ui/scrollbar/src/Scrollbar.tsx index dae7df531..f72f2da71 100644 --- a/packages/ui/scrollbar/src/Scrollbar.tsx +++ b/packages/ui/scrollbar/src/Scrollbar.tsx @@ -9,6 +9,7 @@ import { ScrollbarEventProps, ScrollbarPositionEnum, ScrollbarHelpers, + Settings, } from './types' import { ScrollbarEventToPsMap } from './utils' @@ -28,7 +29,7 @@ export const Scrollbar = forwardRef( style, zIndex, innerRef, - settings, + settings = {}, ...rest }, ref @@ -177,10 +178,10 @@ export interface ScrollbarProps extends HiBaseHTMLProps<'div'>, ScrollbarEventPr */ onlyScrollVisible?: boolean /** - * 原生滚动条配置 + * 滚动条配置 * @default {} */ - settings: Record + settings: Settings } if (__DEV__) { diff --git a/packages/ui/scrollbar/src/types.ts b/packages/ui/scrollbar/src/types.ts index 862214385..8be682b09 100644 --- a/packages/ui/scrollbar/src/types.ts +++ b/packages/ui/scrollbar/src/types.ts @@ -73,3 +73,17 @@ export type ScrollbarPositionEnum = | 'fixed' | 'relative' | 'sticky' + +/** + * 更多配置请参考:https://perfectscrollbar.com/ + */ +export type Settings = PerfectScrollbar.Options & { + /** + * 开启滚动条吸底 + */ + isBottomToScreenBottom?: boolean + /** + * 滚动条吸底距离 + */ + heightFromBottom?: number +} diff --git a/packages/ui/scrollbar/stories/fixed.stories.tsx b/packages/ui/scrollbar/stories/fixed.stories.tsx index e1d190bc5..b25dc9e39 100644 --- a/packages/ui/scrollbar/stories/fixed.stories.tsx +++ b/packages/ui/scrollbar/stories/fixed.stories.tsx @@ -2,8 +2,8 @@ import React, { useRef, useEffect } from 'react' import Scrollbar from '../src' /** - * @title 使能坐标轴 - * @desc 默认 `x`、`y` 都可滚动 + * @title 滚动条固定到屏幕底部 + * @desc 默认不开启 */ export const Fixed = () => { const innerRef = useRef()