generator-nitro
Version:
Yeoman generator for the nitro frontend framework
33 lines (26 loc) • 736 B
JavaScript
;
import { Component, EventListener, GondelBaseComponent } from '@gondel/core';
('Lottie')
class Lottie extends GondelBaseComponent {
start() {
this.initializeAnimation();
}
('click')
_handleClick() {
const action = this.animation.isPaused ? 'play' : 'pause';
this.animation[action]();
}
initializeAnimation() {
const jsonPath = this._ctx.dataset.jsonPath;
import(/* webpackChunkName: "lottie" */ 'lottie-web/build/player/lottie_light.js').then((lottie) => {
this.animation = lottie.loadAnimation({
container: this._ctx,
renderer: 'svg',
loop: true,
autoplay: true,
path: jsonPath,
});
});
}
}
export default Lottie;