@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
44 lines (41 loc) • 1.33 kB
JavaScript
import { isString, isNumber } from 'lodash-unified';
const animateCssPrefix = "animate__";
const animated = (element, animation) => {
const animationName = `${animateCssPrefix}${animation}`;
element.classList.add(`${animateCssPrefix}animated`, animationName);
function handleAnimationEnd(event) {
event.stopPropagation();
element.classList.remove(`${animateCssPrefix}animated`, animationName);
}
element.addEventListener("animationend", handleAnimationEnd, { once: true });
};
const Animate = {
beforeMount(element, binding) {
const value = binding.value;
let animationName = "";
if (isString(value)) {
animationName = value;
} else {
let options;
if ("in" in value) {
options = value.in;
} else {
options = value;
}
const { name, delay, duration, repeat } = options;
if (isNumber(duration)) {
element.style.setProperty("--animate-duration", `${duration}ms`);
}
if (isNumber(delay)) {
element.style.setProperty("--animate-delay", `${delay}ms`);
}
if (isNumber(repeat)) {
element.style.setProperty("--animate-repeat", `${repeat}`);
}
animationName = name;
}
animated(element, animationName);
}
};
export { Animate as default };
//# sourceMappingURL=index.mjs.map