UNPKG

@chakra-xui/transition

Version:

Common transition components for Chakra xui

69 lines (65 loc) 2.18 kB
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; } 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); } import { cx, mergeWith, __DEV__ } from "@chakra-xui/utils"; import { AnimatePresence, motion } from "framer-motion"; import * as React from "react"; import { EASINGS } from "./__utils"; var variants = { exit: props => _extends({ opacity: 0 }, props.reverse ? { scale: props.initialScale } : { transitionEnd: { scale: props.initialScale } }, { transition: { duration: 0.1, ease: EASINGS.easeOut } }), enter: { opacity: 1, scale: 1, transition: { duration: 0.25, ease: EASINGS.easeInOut } } }; export var scaleFadeConfig = { initial: "exit", animate: "enter", exit: "exit", variants }; export var ScaleFade = /*#__PURE__*/React.forwardRef((props, ref) => { var { unmountOnExit, in: isOpen, reverse = true, initialScale = 0.95, className } = props, rest = _objectWithoutPropertiesLoose(props, ["unmountOnExit", "in", "reverse", "initialScale", "className"]); var show = unmountOnExit ? isOpen && unmountOnExit : true; var custom = { initialScale, reverse }; var motionProps = mergeWith(scaleFadeConfig, { custom, animate: isOpen || unmountOnExit ? "enter" : "exit" }); return /*#__PURE__*/React.createElement(AnimatePresence, { custom: custom }, show && /*#__PURE__*/React.createElement(motion.div, _extends({ ref: ref, className: cx("chakra-offset-slide", className) }, motionProps, rest))); }); if (__DEV__) { ScaleFade.displayName = "ScaleFade"; } //# sourceMappingURL=scale-fade.js.map