mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
web: Add extra feature & property
- Support `resize` method - Add `resolution` prop
This commit is contained in:
parent
25ea242d38
commit
f89a40b9b9
1 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue