generator-nitro
Version:
Yeoman generator for the nitro frontend framework
31 lines (25 loc) • 774 B
text/typescript
import { Component, EventListener, GondelBaseComponent } from '@gondel/core';
('Lottie')
export class Lottie extends GondelBaseComponent {
private _animation: any;
public start() {
this._initializeAnimation();
}
('click')
private _handleClick(): void {
const action = this._animation.isPaused ? 'play' : 'pause';
this._animation[action]();
}
private _initializeAnimation(): void {
const jsonPath = this._ctx.dataset.jsonPath;
import(/* webpackChunkName: "lottie" */ 'lottie-web/build/player/lottie_light.js').then((lottie: any) => {
this._animation = lottie.loadAnimation({
container: this._ctx,
renderer: 'svg',
loop: true,
autoplay: true,
path: jsonPath,
});
});
}
}