Add scroll controller

This commit is contained in:
2023-09-08 17:45:37 +08:00
parent 2c09a914ca
commit feebd963a8
7 changed files with 147 additions and 18 deletions

View File

@@ -1,11 +1,17 @@
import React, { PropsWithChildren } from 'react'
import React from 'react'
import '@/assets/css/hide-scrollbar.scss'
const HideScrollbar: React.FC<PropsWithChildren> = (prop: PropsWithChildren) => {
interface HideScrollbarProps extends PropsWithChildren {
getHideScrollbarRef: (hideScrollbarRef: RefObject<HTMLElement>) => void
}
const HideScrollbar: React.FC<HideScrollbarProps> = (props) => {
const hideScrollbarRef = useRef<HTMLDivElement>(null)
const [verticalScrollbarWidth, setVerticalScrollbarWidth] = useState(0)
const [horizontalScrollbarWidth, setHorizontalScrollbarWidth] = useState(0)
props.getHideScrollbarRef(hideScrollbarRef)
useEffect(() => {
const hideScrollbarElement = hideScrollbarRef.current
@@ -42,7 +48,7 @@ const HideScrollbar: React.FC<PropsWithChildren> = (prop: PropsWithChildren) =>
height: `calc(100vh + ${horizontalScrollbarWidth}px`
}}
>
{prop.children}
{props.children}
</div>
</>
)