UNPKG

@vuesax-alpha/nightly

Version:
48 lines (43 loc) 1.46 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var lodashUnified = require('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 (lodashUnified.isString(value)) { animationName = value; } else { let options; if ("in" in value) { options = value.in; } else { options = value; } const { name, delay, duration, repeat } = options; if (lodashUnified.isNumber(duration)) { element.style.setProperty("--animate-duration", `${duration}ms`); } if (lodashUnified.isNumber(delay)) { element.style.setProperty("--animate-delay", `${delay}ms`); } if (lodashUnified.isNumber(repeat)) { element.style.setProperty("--animate-repeat", `${repeat}`); } animationName = name; } animated(element, animationName); } }; exports["default"] = Animate; //# sourceMappingURL=index.js.map