@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
29 lines (26 loc) • 898 B
JavaScript
'use client';
import { useState, useRef, startTransition } from 'react';
import { useWindowEvent, useIsomorphicEffect } from '@mantine/hooks';
function useResizing({ transitionDuration, disabled }) {
const [resizing, setResizing] = useState(true);
const resizingTimeout = useRef();
const disabledTimeout = useRef();
useWindowEvent("resize", () => {
setResizing(true);
clearTimeout(resizingTimeout.current);
resizingTimeout.current = window.setTimeout(() => setResizing(false), 200);
});
useIsomorphicEffect(() => {
startTransition(() => {
setResizing(true);
clearTimeout(disabledTimeout.current);
disabledTimeout.current = window.setTimeout(
() => setResizing(false),
transitionDuration || 0
);
});
}, [disabled, transitionDuration]);
return resizing;
}
export { useResizing };
//# sourceMappingURL=use-resizing.mjs.map