Archived
Template
1
Fork 0
This repository has been archived on 2024-09-04. You can view files and clone it, but cannot push or open issues or pull requests.
Contour/public/@shoelace-style/shoelace/cdn/chunks/chunk.RCZVQXWP.js
2024-01-30 10:59:28 -05:00

46 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
};