Merge branch 'master' of github.com:airbnb/lottie-web
diff --git a/README.md b/README.md
index 1c14a94..2f08c9f 100644
--- a/README.md
+++ b/README.md
@@ -121,7 +121,7 @@
```
You can call lottie.loadAnimation() to start an animation.
It takes an object as a unique param with:
-- animationData: an Object with the exported animation data.
+- animationData: an Object with the exported animation data. **Note:** If your animation contains repeaters and you plan to call loadAnimation multiple times with the same animation, please deep clone the object before passing it (see [#1159](https://github.com/airbnb/lottie-web/issues/1159) and [#2151](https://github.com/airbnb/lottie-web/issues/2151).)
- path: the relative path to the animation object. (animationData and path are mutually exclusive)
- loop: true / false / number
- autoplay: true / false it will start playing as soon as it is ready
@@ -238,6 +238,8 @@
loop: true,
autoplay: true,
animationData: animationData, // the animation data
+ // ...or if your animation contains repeaters:
+ // animationData: cloneDeep(animationData), // e.g. lodash.clonedeep
rendererSettings: {
context: canvasContext, // the canvas context, only support "2d" context
preserveAspectRatio: 'xMinYMin slice', // Supports the same options as the svg element's preserveAspectRatio property
diff --git a/index.d.ts b/index.d.ts
index 3e3f2f1..a81eb88 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -76,15 +76,26 @@
hideOnTransparent?: boolean;
};
-export type AnimationConfig = {
+export type AnimationConfig<T extends 'svg' | 'canvas' | 'html' = 'svg'> = {
container: Element;
- renderer?: 'svg' | 'canvas' | 'html';
+ renderer?: T;
loop?: boolean | number;
autoplay?: boolean;
initialSegment?: AnimationSegment;
name?: string;
assetsPath?: string;
- rendererSettings?: SVGRendererConfig | CanvasRendererConfig | HTMLRendererConfig;
+ rendererSettings?: {
+ svg: SVGRendererConfig;
+ canvas: CanvasRendererConfig;
+ html: HTMLRendererConfig;
+ }[T]
+ audioFactory?(assetPath: string): {
+ play(): void
+ seek(): void
+ playing(): void
+ rate(): void
+ setVolume(): void
+ }
}
export type AnimationConfigWithPath = AnimationConfig & {