UNPKG

@atlaskit/modal-dialog

Version:

A modal dialog displays content that requires user interaction, in a layer above the page.

20 lines 597 B
import { useCallback, useRef } from 'react'; /** * This will run the respective passed in callback functions when modal is * opened or closed. */ export default function useOnMotionFinish({ onOpenComplete, onCloseComplete }) { const motionRef = useRef(null); const onMotionFinish = useCallback(state => { if (state === 'entering' && onOpenComplete) { onOpenComplete(motionRef.current, true); } if (state === 'exiting' && onCloseComplete) { onCloseComplete(motionRef.current); } }, [onOpenComplete, onCloseComplete]); return [motionRef, onMotionFinish]; }