UNPKG

@aarsteinmedia/dotlottie-player

Version:

Web Component for playing Lottie animations in your web app.

47 lines (43 loc) 1.54 kB
import { RendererType, isServer } from '@aarsteinmedia/lottie-web/utils'; export { PlayMode, PlayerEvents, RendererType } from '@aarsteinmedia/lottie-web/utils'; import Lottie from '@aarsteinmedia/lottie-web/svg'; import { D as DotLottiePlayerBase, t as tagName } from './chunks/DotLottiePlayerBase-BBHa6yP8.js'; export { M as MouseOut, P as PlayerState } from './chunks/DotLottiePlayerBase-BBHa6yP8.js'; import '@aarsteinmedia/lottie-web/dotlottie'; /** * DotLottie Player Web Component. */ class DotLottiePlayerSVG extends DotLottiePlayerBase { get renderer() { return RendererType.SVG; } constructor(){ super(); this.isLight = true; } loadAnimation(config) { return Lottie.loadAnimation(config); } setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio }) { const options = { autoplay: hasAutoplay, container, initialSegment, loop: hasLoop, renderer: RendererType.SVG, rendererSettings: { hideOnTransparent: true, imagePreserveAspectRatio: preserveAspectRatio, preserveAspectRatio, progressiveLoad: true } }; return options; } } /** * Expose DotLottiePlayer class as global variable. */ globalThis.dotLottiePlayer = ()=>new DotLottiePlayerSVG(); if (!isServer) { customElements.define(tagName, DotLottiePlayerSVG); } export { DotLottiePlayerSVG as default, tagName };