import BaseFoundation, { DefaultAdapter } from "../base/foundation"; import lottie, { AnimationItem } from "lottie-web"; import { ArgsType } from "../collapse/foundation"; export interface LottieAdapter
, S = Record {
getContainer: () => Element;
getLoadParams: () => ArgsType , S = Record ) {
super({ ...LottieFoundation.defaultAdapter, ...adapter });
}
static getLottie: () => typeof lottie = ()=>{
return lottie;
}
init(lifecycle?: any) {
super.init(lifecycle);
this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
this.getProp("getAnimationInstance")?.(this.animation);
this.getProp("getLottie")?.(LottieFoundation.getLottie());
}
handleParamsUpdate = ()=>{
this.animation.destroy();
this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
this.getProp("getAnimationInstance")?.(this.animation);
}
destroy() {
super.destroy();
this.animation.destroy();
}
}
export default LottieFoundation;