Commit 81fccb17 authored by timel's avatar timel

optimize: overlay scrollbar

parent a0e4c368
Pipeline #22962 failed with stages
in 13 minutes and 41 seconds
import { OverlayScrollbarsComponent } from "overlayscrollbars-react"; import {
OverlayScrollbarsComponent,
OverlayScrollbarsComponentProps,
} from "overlayscrollbars-react";
/**
* @desc 创建漂亮的滚动条,包裹一些可能溢出的元素。
* @why chrome在113之后,取消了overflow: overlay的支持,所以需要使用overlayScrollbars来实现。
*/
export const ScrollableArea: React.FC< export const ScrollableArea: React.FC<
React.ComponentProps<typeof OverlayScrollbarsComponent> React.PropsWithChildren<{
> = ({ options, children, ...rest }) => ( scrollProps?: OverlayScrollbarsComponentProps;
elementProps?: React.HTMLAttributes<HTMLElement>;
className?: string;
style?: React.CSSProperties;
}>
> = ({ scrollProps = {}, elementProps, className, style, children }) => {
const { options = {}, ...rest } = scrollProps;
scrollProps;
return (
<OverlayScrollbarsComponent <OverlayScrollbarsComponent
options={{ options={{
scrollbars: { scrollbars: {
...@@ -16,8 +31,14 @@ export const ScrollableArea: React.FC< ...@@ -16,8 +31,14 @@ export const ScrollableArea: React.FC<
...options, ...options,
}} }}
defer defer
style={{
height: "100%",
}}
{...rest} {...rest}
> >
<div className={className} style={style} {...elementProps}>
{children} {children}
</div>
</OverlayScrollbarsComponent> </OverlayScrollbarsComponent>
); );
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment