UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

16 lines (15 loc) 550 B
import { useState as o, useRef as u, useCallback as f, useEffect as l } from "../external/preact/hooks/dist/hooks.module.js"; const m = (e = 1e3, a = !1) => { const [r, s] = o(a), t = u(), n = u(), c = f(() => { r || (n.current = setTimeout(() => { t.current = requestAnimationFrame(() => s(!1)); }, e), s(!0)); }, [r, e]); return l(() => () => { cancelAnimationFrame(t.current), clearTimeout(n.current), t.current = n.current = null; }, [e]), { freeze: c, frozen: r }; }; export { m as default, m as useFreezePeriod };