mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-07 05:01:40 +00:00
25 lines
761 B
TypeScript
25 lines
761 B
TypeScript
import { useTimeout } from '@mantine/hooks';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export const useHideScrollbar = (timeout: number) => {
|
|
const [hideScrollbar, setHideScrollbar] = useState(false);
|
|
const { clear, start } = useTimeout(() => setHideScrollbar(true), timeout);
|
|
|
|
// Automatically hide the scrollbar after the timeout duration
|
|
useEffect(() => {
|
|
start();
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, []);
|
|
|
|
const hideScrollbarElementProps = {
|
|
onMouseEnter: () => {
|
|
setHideScrollbar(false);
|
|
clear();
|
|
},
|
|
onMouseLeave: () => {
|
|
start();
|
|
},
|
|
};
|
|
|
|
return { hideScrollbarElementProps, isScrollbarHidden: hideScrollbar };
|
|
};
|