web: Add extra feature & property

- Support `resize` method
- Add `resolution` prop
This commit is contained in:
Jinny You 2024-01-04 16:56:46 +09:00 committed by Hermet Park
parent 25ea242d38
commit f89a40b9b9

View file

@ -252,6 +252,15 @@ export class LottiePlayer extends LitElement {
@property({ type: Number })
public currentState: PlayerState = PlayerState.Loading;
/**
* original size of the animation (readonly)
* @since 1.0
*/
@property({ type: Float32Array })
public get size(): Float32Array {
return Float32Array.from(this._TVG?.size() || [0, 0]);
}
private _TVG?: TvgModule;
private _canvas?: HTMLCanvasElement;
private _imageData?: ImageData;
@ -491,6 +500,21 @@ export class LottiePlayer extends LitElement {
this._render();
}
/**
* Adjust the canvas size.
* @param width The width to resize
* @param height The height to resize
* @since 1.0
*/
public resize(width: number, height: number) {
this._canvas!.width = width;
this._canvas!.height = height;
if (this.currentState !== PlayerState.Playing) {
this._render();
}
}
/**
* Destroy animation and lottie-player element.
* @since 1.0