@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
1 lines • 1.18 kB
Source Map (JSON)
{"version":3,"file":"useDelayedAnimated.mjs","names":[],"sources":["../../../src/Markdown/components/useDelayedAnimated.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport const useDelayedAnimated = (animated?: boolean) => {\n const [delayedAnimated, setDelayedAnimated] = useState(animated);\n\n // Watch for changes in animated prop\n useEffect(() => {\n if (animated === undefined) return;\n // If animated changes from true to false, delay the update by 1 second\n if (animated === false && delayedAnimated === true) {\n const timer = setTimeout(() => {\n setDelayedAnimated(false);\n }, 1000);\n\n return () => clearTimeout(timer);\n } else {\n // For any other changes, update immediately\n setDelayedAnimated(animated);\n }\n }, [animated, delayedAnimated]);\n\n return delayedAnimated;\n};\n"],"mappings":";;AAEA,MAAa,sBAAsB,aAAuB;CACxD,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,QAAQ;CAG/D,gBAAgB;EACd,IAAI,aAAa,KAAA,GAAW;EAE5B,IAAI,aAAa,SAAS,oBAAoB,MAAM;GAClD,MAAM,QAAQ,iBAAiB;IAC7B,mBAAmB,KAAK;GAC1B,GAAG,GAAI;GAEP,aAAa,aAAa,KAAK;EACjC,OAEE,mBAAmB,QAAQ;CAE/B,GAAG,CAAC,UAAU,eAAe,CAAC;CAE9B,OAAO;AACT"}