@yamada-ui/motion
Version:
Yamada UI motion components
120 lines (119 loc) • 3.6 kB
JavaScript
"use client"
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils.ts
var utils_exports = {};
__export(utils_exports, {
MOTION_TRANSITION_DEFAULTS: () => MOTION_TRANSITION_DEFAULTS,
MOTION_TRANSITION_EASINGS: () => MOTION_TRANSITION_EASINGS,
MOTION_TRANSITION_VARIANTS: () => MOTION_TRANSITION_VARIANTS,
transitionEnter: () => transitionEnter,
transitionExit: () => transitionExit
});
module.exports = __toCommonJS(utils_exports);
var import_utils = require("@yamada-ui/utils");
var MOTION_TRANSITION_EASINGS = {
ease: [0.25, 0.1, 0.25, 1],
easeIn: [0.4, 0, 1, 1],
easeInOut: [0.4, 0, 0.2, 1],
easeOut: [0, 0, 0.2, 1]
};
var MOTION_TRANSITION_VARIANTS = {
fade: {
enter: { opacity: 1 },
exit: { opacity: 0 }
},
pushDown: {
enter: { y: "-100%" },
exit: { y: "30%" }
},
pushLeft: {
enter: { x: "100%" },
exit: { x: "-30%" }
},
pushRight: {
enter: { x: "-100%" },
exit: { x: "30%" }
},
pushUp: {
enter: { y: "100%" },
exit: { y: "-30%" }
},
scale: {
enter: { scale: 1 },
exit: { scale: 0.95 }
},
slideDown: {
enter: { x: 0, y: 0 },
exit: { x: 0, y: "100%" },
position: { bottom: 0, left: 0, maxWidth: "100vw", right: 0 }
},
slideLeft: {
enter: { x: 0, y: 0 },
exit: { x: "-100%", y: 0 },
position: { bottom: 0, left: 0, top: 0, width: "100%" }
},
slideRight: {
enter: { x: 0, y: 0 },
exit: { x: "100%", y: 0 },
position: { bottom: 0, right: 0, top: 0, width: "100%" }
},
slideUp: {
enter: { x: 0, y: 0 },
exit: { x: 0, y: "-100%" },
position: { left: 0, maxWidth: "100vw", right: 0, top: 0 }
}
};
var MOTION_TRANSITION_DEFAULTS = {
enter: {
duration: 0.25,
ease: MOTION_TRANSITION_EASINGS.easeOut
},
exit: {
duration: 0.2,
ease: MOTION_TRANSITION_EASINGS.easeIn
}
};
function transitionEnter(transition) {
return function(delay, duration) {
return {
...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.enter,
...duration ? { duration: (0, import_utils.isNumber)(duration) ? duration : duration.enter } : {},
delay: (0, import_utils.isNumber)(delay) ? delay : delay == null ? void 0 : delay.enter
};
};
}
function transitionExit(transition) {
return function(delay, duration) {
return {
...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.exit,
...duration ? { duration: (0, import_utils.isNumber)(duration) ? duration : duration.exit } : {},
delay: (0, import_utils.isNumber)(delay) ? delay : delay == null ? void 0 : delay.exit
};
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MOTION_TRANSITION_DEFAULTS,
MOTION_TRANSITION_EASINGS,
MOTION_TRANSITION_VARIANTS,
transitionEnter,
transitionExit
});
//# sourceMappingURL=utils.js.map