@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
1 lines • 1.76 kB
Source Map (JSON)
{"version":3,"file":"use-resizing.cjs","names":[],"sources":["../../../../src/components/AppShell/use-resizing/use-resizing.tsx"],"sourcesContent":["import { startTransition, useRef, useState } from 'react';\nimport { useIsomorphicEffect, useWindowEvent } from '@mantine/hooks';\n\ninterface UseResizingInput {\n transitionDuration: number | undefined;\n disabled: boolean | undefined;\n}\n\nexport function useResizing({ transitionDuration, disabled }: UseResizingInput) {\n const [resizing, setResizing] = useState(true);\n const resizingTimeout = useRef<number>(-1);\n const disabledTimeout = useRef<number>(-1);\n\n useWindowEvent('resize', () => {\n setResizing(true);\n clearTimeout(resizingTimeout.current);\n resizingTimeout.current = window.setTimeout(\n () =>\n startTransition(() => {\n setResizing(false);\n }),\n 200\n );\n });\n\n useIsomorphicEffect(() => {\n setResizing(true);\n clearTimeout(disabledTimeout.current);\n disabledTimeout.current = window.setTimeout(\n () =>\n startTransition(() => {\n setResizing(false);\n }),\n transitionDuration || 0\n );\n }, [disabled, transitionDuration]);\n\n return resizing;\n}\n"],"mappings":";;;;;AAQA,SAAgB,YAAY,EAAE,oBAAoB,YAA8B;CAC9E,MAAM,CAAC,UAAU,gBAAA,GAAA,MAAA,UAAwB,KAAK;CAC9C,MAAM,mBAAA,GAAA,MAAA,QAAiC,GAAG;CAC1C,MAAM,mBAAA,GAAA,MAAA,QAAiC,GAAG;AAE1C,EAAA,GAAA,eAAA,gBAAe,gBAAgB;AAC7B,cAAY,KAAK;AACjB,eAAa,gBAAgB,QAAQ;AACrC,kBAAgB,UAAU,OAAO,kBAAA,GAAA,MAAA,uBAEP;AACpB,eAAY,MAAM;IAClB,EACJ,IACD;GACD;AAEF,EAAA,GAAA,eAAA,2BAA0B;AACxB,cAAY,KAAK;AACjB,eAAa,gBAAgB,QAAQ;AACrC,kBAAgB,UAAU,OAAO,kBAAA,GAAA,MAAA,uBAEP;AACpB,eAAY,MAAM;IAClB,EACJ,sBAAsB,EACvB;IACA,CAAC,UAAU,mBAAmB,CAAC;AAElC,QAAO"}