@chakra-xui/transition
Version:
Common transition components for Chakra xui
51 lines (47 loc) • 1.79 kB
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { cx, __DEV__ } from "@chakra-xui/utils";
import { AnimatePresence, motion } from "framer-motion";
import * as React from "react";
import { EASINGS } from "./__utils";
var variants = {
exit: {
opacity: 0,
transition: {
duration: 0.1,
ease: EASINGS.easeOut
}
},
enter: {
opacity: 1,
transition: {
duration: 0.2,
ease: EASINGS.easeIn
}
}
};
export var fadeConfig = {
initial: "exit",
animate: "enter",
exit: "exit",
variants
};
export var Fade = /*#__PURE__*/React.forwardRef((props, ref) => {
var {
unmountOnExit,
in: isOpen,
className
} = props,
rest = _objectWithoutPropertiesLoose(props, ["unmountOnExit", "in", "className"]);
var shouldExpand = unmountOnExit ? isOpen && unmountOnExit : true;
return /*#__PURE__*/React.createElement(AnimatePresence, null, shouldExpand && /*#__PURE__*/React.createElement(motion.div, _extends({
ref: ref,
className: cx("chakra-fade", className)
}, fadeConfig, {
animate: isOpen || unmountOnExit ? "enter" : "exit"
}, rest)));
});
if (__DEV__) {
Fade.displayName = "Fade";
}
//# sourceMappingURL=fade.js.map