47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
|
import {
|
||
|
__spreadProps,
|
||
|
__spreadValues
|
||
|
} from "./chunk.KIILAQWQ.js";
|
||
|
|
||
|
// src/utilities/animation-registry.ts
|
||
|
var defaultAnimationRegistry = /* @__PURE__ */ new Map();
|
||
|
var customAnimationRegistry = /* @__PURE__ */ new WeakMap();
|
||
|
function ensureAnimation(animation) {
|
||
|
return animation != null ? animation : { keyframes: [], options: { duration: 0 } };
|
||
|
}
|
||
|
function getLogicalAnimation(animation, dir) {
|
||
|
if (dir.toLowerCase() === "rtl") {
|
||
|
return {
|
||
|
keyframes: animation.rtlKeyframes || animation.keyframes,
|
||
|
options: animation.options
|
||
|
};
|
||
|
}
|
||
|
return animation;
|
||
|
}
|
||
|
function setDefaultAnimation(animationName, animation) {
|
||
|
defaultAnimationRegistry.set(animationName, ensureAnimation(animation));
|
||
|
}
|
||
|
function setAnimation(el, animationName, animation) {
|
||
|
customAnimationRegistry.set(el, __spreadProps(__spreadValues({}, customAnimationRegistry.get(el)), { [animationName]: ensureAnimation(animation) }));
|
||
|
}
|
||
|
function getAnimation(el, animationName, options) {
|
||
|
const customAnimation = customAnimationRegistry.get(el);
|
||
|
if (customAnimation == null ? void 0 : customAnimation[animationName]) {
|
||
|
return getLogicalAnimation(customAnimation[animationName], options.dir);
|
||
|
}
|
||
|
const defaultAnimation = defaultAnimationRegistry.get(animationName);
|
||
|
if (defaultAnimation) {
|
||
|
return getLogicalAnimation(defaultAnimation, options.dir);
|
||
|
}
|
||
|
return {
|
||
|
keyframes: [],
|
||
|
options: { duration: 0 }
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export {
|
||
|
setDefaultAnimation,
|
||
|
setAnimation,
|
||
|
getAnimation
|
||
|
};
|