UNPKG

@tamnt-work/lottie-vue

Version:

Render Lottie for VueJS

1 lines 2.86 kB
var LottieVue=function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(t),i=r(n);function a(e,t,n,r,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function u(e){a(i,r,o,u,s,"next",e)}function s(e){a(i,r,o,u,s,"throw",e)}u(void 0)}))}}function s(e,t,n,r,o,i,a,u,s,d){"boolean"!=typeof a&&(s=u,u=a,a=!1);const c="function"==typeof n?n.options:n;let f;if(e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,o&&(c.functional=!0)),r&&(c._scopeId=r),i?(f=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,s(e)),e&&e._registeredComponents&&e._registeredComponents.add(i)},c._ssrRegister=f):t&&(f=a?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,u(e))}),f)if(c.functional){const e=c.render;c.render=function(t,n){return f.call(n),e(t,n)}}else{const e=c.beforeCreate;c.beforeCreate=e?[].concat(e,f):[f]}return n}var d=s({render:function(){var e=this.$createElement;return(this._self._c||e)("div",{ref:"lottie"})},staticRenderFns:[]},void 0,{props:{path:{type:String,required:!0,default:function(){return""}},renderer:{type:String,required:!1,default:function(){return"canvas"}},loop:{type:Boolean,required:!1,default:!0},autoplay:{type:Boolean,required:!1,default:!0}},watch:{path:function(){var e=this;return u(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.onLoad();case 2:case"end":return t.stop()}}),t)})))()}},mounted:function(){var e=this;return u(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.onLoad();case 2:case"end":return t.stop()}}),t)})))()},methods:{onLoad:function(){var e=this;return u(regeneratorRuntime.mark((function t(){var n,r,a,u,s,d,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.$props,r=n.path,a=n.renderer,u=n.loop,s=n.autoplay,t.next=3,i.default.get(r);case 3:d=t.sent,c=d.data,e.$refs.lottie.innerHTML="",o.default.loadAnimation({animationData:c,container:e.$refs.lottie,renderer:a,loop:u,autoplay:s});case 7:case"end":return t.stop()}}),t)})))()}}},void 0,!1,void 0,!1,void 0,void 0,void 0),c=function(e){c.installed||(c.installed=!0,e.component("LottieVue",d))},f={install:c},l=null;return"undefined"!=typeof window?l=window.Vue:"undefined"!=typeof global&&(l=global.Vue),l&&l.use(f),d.install=c,e.default=d,Object.defineProperty(e,"__esModule",{value:!0}),e}({},lottie,axios);