Upgrade HideScrollbar

This commit is contained in:
2024-02-20 11:18:24 +08:00
parent 48ff94a2c9
commit 9ab8a0268c

View File

@@ -1,4 +1,11 @@
import { TouchEvent, MouseEvent, KeyboardEvent, DetailedHTMLProps, HTMLAttributes } from 'react' import {
TouchEvent,
MouseEvent,
KeyboardEvent,
DetailedHTMLProps,
HTMLAttributes,
UIEvent
} from 'react'
import '@/assets/css/components/common/hide-scrollbar.scss' import '@/assets/css/components/common/hide-scrollbar.scss'
interface HideScrollbarProps interface HideScrollbarProps
@@ -63,6 +70,7 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
minHeight, minHeight,
scrollbarWidth, scrollbarWidth,
autoHideWaitingTime, autoHideWaitingTime,
onScroll,
children, children,
style, style,
className, className,
@@ -406,7 +414,8 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
} }
} }
const handleDefaultScroll = () => { const handleDefaultScroll = (event: UIEvent<HTMLDivElement>) => {
onScroll?.(event)
setVerticalScrollbarPosition( setVerticalScrollbarPosition(
((rootRef.current?.scrollTop ?? 0) / (contentRef.current?.clientHeight ?? 1)) * 100 ((rootRef.current?.scrollTop ?? 0) / (contentRef.current?.clientHeight ?? 1)) * 100
) )
@@ -482,7 +491,6 @@ const HideScrollbar = forwardRef<HideScrollbarElement, HideScrollbarProps>(
length = prevState length = prevState
return prevState return prevState
}) })
console.log(length)
if ( if (
!isPreventHorizontalScroll && !isPreventHorizontalScroll &&
length >= 100 && length >= 100 &&