Add customizable scrollbar offset on scrollarea
This commit is contained in:
parent
c51194cd03
commit
d58ba92cbd
1 changed files with 13 additions and 5 deletions
|
@ -26,16 +26,16 @@ const StyledScrollArea = styled(MantineScrollArea)`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledNativeScrollArea = styled.div`
|
const StyledNativeScrollArea = styled.div<{ scrollBarOffset?: string }>`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: overlay;
|
overflow-y: overlay !important;
|
||||||
|
|
||||||
&::-webkit-scrollbar-track {
|
&::-webkit-scrollbar-track {
|
||||||
margin-top: 35px;
|
margin-top: ${(props) => props.scrollBarOffset || '35px'};
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-webkit-scrollbar-thumb {
|
&::-webkit-scrollbar-thumb {
|
||||||
margin-top: 35px;
|
margin-top: ${(props) => props.scrollBarOffset || '35px'};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -55,11 +55,18 @@ interface NativeScrollAreaProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
debugScrollPosition?: boolean;
|
debugScrollPosition?: boolean;
|
||||||
pageHeaderProps?: PageHeaderProps & { offset?: any; target?: any };
|
pageHeaderProps?: PageHeaderProps & { offset?: any; target?: any };
|
||||||
|
scrollBarOffset?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NativeScrollArea = forwardRef(
|
export const NativeScrollArea = forwardRef(
|
||||||
(
|
(
|
||||||
{ children, pageHeaderProps, debugScrollPosition, ...props }: NativeScrollAreaProps,
|
{
|
||||||
|
children,
|
||||||
|
pageHeaderProps,
|
||||||
|
debugScrollPosition,
|
||||||
|
scrollBarOffset,
|
||||||
|
...props
|
||||||
|
}: NativeScrollAreaProps,
|
||||||
ref: Ref<HTMLDivElement>,
|
ref: Ref<HTMLDivElement>,
|
||||||
) => {
|
) => {
|
||||||
const [hideScrollbar, setHideScrollbar] = useState(false);
|
const [hideScrollbar, setHideScrollbar] = useState(false);
|
||||||
|
@ -112,6 +119,7 @@ export const NativeScrollArea = forwardRef(
|
||||||
<StyledNativeScrollArea
|
<StyledNativeScrollArea
|
||||||
ref={mergedRef}
|
ref={mergedRef}
|
||||||
className={hideScrollbar ? 'hide-scrollbar' : undefined}
|
className={hideScrollbar ? 'hide-scrollbar' : undefined}
|
||||||
|
scrollBarOffset={scrollBarOffset}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setHideScrollbar(false);
|
setHideScrollbar(false);
|
||||||
clear();
|
clear();
|
||||||
|
|
Reference in a new issue