@atlaskit/modal-dialog
Version:
A modal dialog displays content that requires user interaction, in a layer above the page.
25 lines (24 loc) • 766 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useOnMotionFinish;
var _react = require("react");
/**
* This will run the respective passed in callback functions when modal is
* opened or closed.
*/
function useOnMotionFinish(_ref) {
var onOpenComplete = _ref.onOpenComplete,
onCloseComplete = _ref.onCloseComplete;
var motionRef = (0, _react.useRef)(null);
var onMotionFinish = (0, _react.useCallback)(function (state) {
if (state === 'entering' && onOpenComplete) {
onOpenComplete(motionRef.current, true);
}
if (state === 'exiting' && onCloseComplete) {
onCloseComplete(motionRef.current);
}
}, [onOpenComplete, onCloseComplete]);
return [motionRef, onMotionFinish];
}