You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3 lines
6.8 KiB
3 lines
6.8 KiB
(function(){"use strict";try{if(typeof document!="undefined"){var t=document.createElement("style");t.appendChild(document.createTextNode(".lottie-animation-container{width:var(--lottie-animation-container-width);height:var(--lottie-animation-container-height);background-color:var(--lottie-animation-container-background-color);overflow:hidden;margin:var(--lottie-animation-margin)}.lottie-animation-container svg{transform:scale(var(--lottie-animation-scale))}")),document.head.appendChild(t)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
|
|
"use strict";var w=Object.defineProperty,D=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var c=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var y=(t,r,n)=>r in t?w(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,m=(t,r)=>{for(var n in r||(r={}))j.call(r,n)&&y(t,n,r[n]);if(c)for(var n of c(r))_.call(r,n)&&y(t,n,r[n]);return t},g=(t,r)=>D(t,L(r));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var f=require("vue"),b=require("lottie-web");function E(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var C=E(b),p=function t(r,n){if(r===n)return!0;if(r&&n&&typeof r=="object"&&typeof n=="object"){if(r.constructor!==n.constructor)return!1;var a,e,u;if(Array.isArray(r)){if(a=r.length,a!=n.length)return!1;for(e=a;e--!==0;)if(!t(r[e],n[e]))return!1;return!0}if(r instanceof Map&&n instanceof Map){if(r.size!==n.size)return!1;for(e of r.entries())if(!n.has(e[0]))return!1;for(e of r.entries())if(!t(e[1],n.get(e[0])))return!1;return!0}if(r instanceof Set&&n instanceof Set){if(r.size!==n.size)return!1;for(e of r.entries())if(!n.has(e[0]))return!1;return!0}if(ArrayBuffer.isView(r)&&ArrayBuffer.isView(n)){if(a=r.length,a!=n.length)return!1;for(e=a;e--!==0;)if(r[e]!==n[e])return!1;return!0}if(r.constructor===RegExp)return r.source===n.source&&r.flags===n.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===n.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===n.toString();if(u=Object.keys(r),a=u.length,a!==Object.keys(n).length)return!1;for(e=a;e--!==0;)if(!Object.prototype.hasOwnProperty.call(n,u[e]))return!1;for(e=a;e--!==0;){var l=u[e];if(!t(r[l],n[l]))return!1}return!0}return r!==r&&n!==n};function d(t){var r,n,a;if(Array.isArray(t)){for(n=Array(r=t.length);r--;)n[r]=(a=t[r])&&typeof a=="object"?d(a):a;return n}if(Object.prototype.toString.call(t)==="[object Object]"){n={};for(r in t)r==="__proto__"?Object.defineProperty(n,r,{value:d(t[r]),configurable:!0,enumerable:!0,writable:!0}):n[r]=(a=t[r])&&typeof a=="object"?d(a):a;return n}return t}var H=(t,r)=>{const n=t.__vccOpts||t;for(const[a,e]of r)n[a]=e;return n};const P=f.defineComponent({props:{animationData:{type:Object,default:()=>({})},animationLink:{type:String,default:""},loop:{type:[Boolean,Number],default:!0},autoPlay:{type:Boolean,default:!0},width:{type:[Number,String],default:"100%"},height:{type:[Number,String],default:"100%"},speed:{type:Number,default:1},delay:{type:Number,default:0},direction:{type:String,default:"forward"},pauseOnHover:{type:Boolean,default:!1},playOnHover:{type:Boolean,default:!1},backgroundColor:{type:String,default:"transparent"},pauseAnimation:{type:Boolean,default:!1},noMargin:{type:Boolean,default:!1},scale:{type:Number,default:1},renderer:{type:String,default:"svg"},rendererSettings:{type:Object,default:()=>({})},assetsPath:{type:String,default:""}},emits:{onComplete:null,onLoopComplete:null,onEnterFrame:null,onSegmentStart:null,onAnimationLoaded:null},setup(t,{emit:r}){const n=f.ref();let a,e=null,u=1;f.watchEffect(async()=>{if(!!n.value){if(t.animationLink!="")try{a=await(await fetch(t.animationLink)).json()}catch(o){console.error(o);return}else if(p(t.animationData,{})===!1)a=d(t.animationData);else throw new Error("You must provide either animationLink or animationData");l()}});const l=()=>{if(!n.value||!a)return;e==null||e.destroy(),e=null;let o=t.autoPlay,i=t.loop;t.playOnHover&&(o=!1),typeof i=="number"&&i>0&&(i=i-1),t.delay>0&&(o=!1);const s={container:n.value,renderer:t.renderer,loop:i,autoplay:o,animationData:a,assetsPath:t.assetsPath};p(t.rendererSettings,{})===!1&&(s.rendererSettings=t.rendererSettings),t.scale!==1&&(s.rendererSettings=g(m({},s.rendererSettings),{viewBoxOnly:!0})),e=C.default.loadAnimation(s),setTimeout(()=>{o=t.autoPlay,t.playOnHover?e==null||e.pause():o?e==null||e.play():e==null||e.pause(),r("onAnimationLoaded")},t.delay),e.setSpeed(t.speed),t.direction==="reverse"&&e.setDirection(-1),t.direction==="normal"&&e.setDirection(1),(t.pauseAnimation||t.playOnHover)&&e.pause(),e.addEventListener("loopComplete",()=>{t.direction==="alternate"&&(e==null||e.stop(),u=u===-1?1:-1,e==null||e.setDirection(u),e==null||e.play()),r("onLoopComplete")}),e.addEventListener("complete",()=>{r("onComplete")}),e.addEventListener("enterFrame",()=>{r("onEnterFrame")}),e.addEventListener("segmentStart",()=>{r("onSegmentStart")})},S=f.computed(()=>{let o=t.width,i=t.height;return typeof t.width=="number"&&(o=`${t.width}px`),typeof t.height=="number"&&(i=`${t.height}px`),{"--lottie-animation-container-width":o,"--lottie-animation-container-height":i,"--lottie-animation-container-background-color":t.backgroundColor,"--lottie-animation-margin":t.noMargin?"0":"0 auto","--lottie-animation-scale":t.scale!=1?t.scale:""}}),h=()=>{e&&t.pauseOnHover&&e.pause(),e&&t.playOnHover&&e.play()},O=()=>{e&&t.pauseOnHover&&e.play(),e&&t.playOnHover&&e.pause()};return f.watch(()=>t.pauseAnimation,()=>{if((t.pauseOnHover||t.playOnHover)&&t.pauseAnimation){console.error("If you are using pauseAnimation prop for Vue3-Lottie, please remove the props pauseOnHover and playOnHover");return}e&&(t.pauseAnimation?e.pause():e.play())}),{lottieAnimationContainer:n,hoverEnded:O,hoverStarted:h,getCurrentStyle:S,play:()=>{e&&e.play()},pause:()=>{e&&e.pause()},stop:()=>{e&&e.stop()},destroy:()=>{e&&e.destroy()},setSpeed:(o=1)=>{if(o<=0)throw new Error("Speed must be greater than 0");e&&e.setSpeed(o)},setDirection:o=>{e&&(o==="forward"?e.setDirection(1):o==="reverse"&&e.setDirection(-1))},goToAndStop:(o,i=!0)=>{e&&e.goToAndStop(o,i)},goToAndPlay:(o,i=!0)=>{e&&e.goToAndPlay(o,i)},playSegments:(o,i=!1)=>{e&&e.playSegments(o,i)},setSubFrame:(o=!0)=>{e&&e.setSubframe(o)},getDuration:(o=!0)=>{if(e)return e.getDuration(o)},updateDocumentData:(o,i=0)=>{e&&e.renderer.elements[i].updateDocumentData(o)}}}});function A(t,r,n,a,e,u){return f.openBlock(),f.createElementBlock("div",{ref:"lottieAnimationContainer",class:"lottie-animation-container",style:f.normalizeStyle(t.getCurrentStyle),onMouseenter:r[0]||(r[0]=(...l)=>t.hoverStarted&&t.hoverStarted(...l)),onMouseleave:r[1]||(r[1]=(...l)=>t.hoverEnded&&t.hoverEnded(...l))},null,36)}var v=H(P,[["render",A]]),B={install(t,r){var a;const n=(a=r==null?void 0:r.name)!=null?a:"Vue3Lottie";t.component(n,v)}};exports.Vue3Lottie=v;exports.default=B;
|