UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

32 lines (31 loc) 1.3 kB
import React from "react"; interface useOpenChangeAnimationCompleteParameters { /** * Enable / disable the effect. Disabled => no animation tracking / callback. * @default true */ enabled?: boolean; /** * Current open state (e.g. popover open). When this flips we wait for any * associated CSS/Web animations on `ref` to finish before firing `onComplete`. */ open?: boolean; /** * Element whose animations/transition we observe. Should be stable while the * open/close animation runs (typically the root animated node). */ ref?: React.RefObject<HTMLElement | null>; /** * Called exactly once per open-change cycle after animations finish OR * immediately if animations are disabled / unsupported. */ onComplete: () => void; } /** * Waits for the element's current Web Animations / CSS transitions to finish after an * `open` state change, then invokes `onComplete`. Guards against race conditions by * comparing the `open` value captured at scheduling time with the latest `open` via ref; * if they differ (state flipped again mid‑animation) the callback is skipped. */ export declare function useOpenChangeAnimationComplete(parameters: useOpenChangeAnimationCompleteParameters): void; export {};