@aarsteinmedia/dotlottie-player
Version:
Web Component for playing Lottie animations in your web app.
47 lines (43 loc) • 1.55 kB
JavaScript
import { RendererType, isServer } from '@aarsteinmedia/lottie-web/utils';
export { PlayMode, PlayerEvents, RendererType } from '@aarsteinmedia/lottie-web/utils';
import Lottie from '@aarsteinmedia/lottie-web/light';
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 DotLottiePlayerLight 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 DotLottiePlayerLight();
if (!isServer) {
customElements.define(tagName, DotLottiePlayerLight);
}
export { DotLottiePlayerLight as default, tagName };