Add scrollbar width setting to HideScrollbar

This commit is contained in:
2023-10-13 11:33:14 +08:00
parent a8129e8aff
commit 91d5480780
2 changed files with 19 additions and 5 deletions

View File

@@ -48,19 +48,25 @@
.vertical-scrollbar { .vertical-scrollbar {
padding: 12px 4px; padding: 12px 4px;
width: 16px;
height: 100%; height: 100%;
left: 100%; left: 100%;
top: 0; top: 0;
transform: translateX(-100%); transform: translateX(-100%);
.box {
width: 8px;
}
} }
.horizontal-scrollbar { .horizontal-scrollbar {
padding: 4px 12px; padding: 4px 12px;
width: 100%; width: 100%;
height: 16px;
left: 0; left: 0;
top: 100%; top: 100%;
transform: translateY(-100%); transform: translateY(-100%);
.box {
height: 8px;
}
} }
} }

View File

@@ -11,6 +11,8 @@ interface HideScrollbarProps
isShowHorizontalScrollbar?: boolean isShowHorizontalScrollbar?: boolean
isHiddenHorizontalScrollbarWhenFull?: boolean isHiddenHorizontalScrollbarWhenFull?: boolean
minWidth?: string | number minWidth?: string | number
minHeight?: string | number
scrollbarWidth?: string | number
} }
export interface HideScrollbarElement { export interface HideScrollbarElement {
@@ -159,6 +161,8 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>((prop
isShowHorizontalScrollbar, isShowHorizontalScrollbar,
isHiddenHorizontalScrollbarWhenFull, isHiddenHorizontalScrollbarWhenFull,
minWidth, minWidth,
minHeight,
scrollbarWidth,
..._props ..._props
} = props } = props
@@ -471,7 +475,11 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>((prop
onTouchMove={isPreventAnyScroll ? handleDefaultTouchmove : undefined} onTouchMove={isPreventAnyScroll ? handleDefaultTouchmove : undefined}
onScroll={handleDefaultScroll} onScroll={handleDefaultScroll}
> >
<div className={'hide-scrollbar-content'} ref={contentRef} style={{ minWidth }}> <div
className={'hide-scrollbar-content'}
ref={contentRef}
style={{ minWidth, minHeight }}
>
{props.children} {props.children}
</div> </div>
</div> </div>
@@ -490,7 +498,7 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>((prop
: undefined : undefined
}} }}
> >
<div className={'box'}> <div className={'box'} style={{ width: scrollbarWidth }}>
<div <div
className={'block'} className={'block'}
style={{ style={{
@@ -527,7 +535,7 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>((prop
: undefined : undefined
}} }}
> >
<div className={'box'}> <div className={'box'} style={{ height: scrollbarWidth }}>
<div <div
className={'block'} className={'block'}
style={{ style={{