From a48af3da92902ff2bd2653e01fe2d1bba19ef54d Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Fri, 13 Oct 2023 17:51:38 +0800 Subject: [PATCH] Optimize HideScrollbar --- src/components/common/HideScrollbar.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/common/HideScrollbar.tsx b/src/components/common/HideScrollbar.tsx index 2cf3b8f..f86e5fb 100644 --- a/src/components/common/HideScrollbar.tsx +++ b/src/components/common/HideScrollbar.tsx @@ -45,6 +45,7 @@ export interface HideScrollbarElement { listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions ): void + refreshLayout(): void } const HideScrollbar = forwardRef((props, ref) => { @@ -128,6 +129,9 @@ const HideScrollbar = forwardRef((prop options?: boolean | EventListenerOptions ): void { rootRef.current?.removeEventListener(type, listener, options) + }, + refreshLayout(): void { + setRefreshTime(Date.now()) } } }, @@ -141,6 +145,7 @@ const HideScrollbar = forwardRef((prop const lastScrollbarClickPositionRef = useRef({ x: -1, y: -1 }) const lastScrollbarTouchPositionRef = useRef({ x: -1, y: -1 }) const lastTouchPositionRef = useRef({ x: -1, y: -1 }) + const [refreshTime, setRefreshTime] = useState(0) const [verticalScrollbarWidth, setVerticalScrollbarWidth] = useState(0) const [verticalScrollbarLength, setVerticalScrollbarLength] = useState(100) const [verticalScrollbarPosition, setVerticalScrollbarPosition] = useState(0) @@ -479,6 +484,7 @@ const HideScrollbar = forwardRef((prop className={'hide-scrollbar-content'} ref={contentRef} style={{ minWidth, minHeight }} + data-refresh={refreshTime} > {props.children}