RLottie: Fix redundant render
This commit is contained in:
parent
b86d857277
commit
9f8fe22f3c
@ -39,9 +39,9 @@ class RLottie {
|
|||||||
private containers = new Map<HTMLDivElement, {
|
private containers = new Map<HTMLDivElement, {
|
||||||
canvas: HTMLCanvasElement;
|
canvas: HTMLCanvasElement;
|
||||||
ctx: CanvasRenderingContext2D;
|
ctx: CanvasRenderingContext2D;
|
||||||
onLoad?: NoneToVoidFunction;
|
isLoaded?: boolean;
|
||||||
isOnLoadFired?: boolean;
|
|
||||||
isPaused?: boolean;
|
isPaused?: boolean;
|
||||||
|
onLoad?: NoneToVoidFunction;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
private imgSize!: number;
|
private imgSize!: number;
|
||||||
@ -372,21 +372,17 @@ class RLottie {
|
|||||||
|
|
||||||
this.containers.forEach((containerData) => {
|
this.containers.forEach((containerData) => {
|
||||||
const {
|
const {
|
||||||
ctx, onLoad, isOnLoadFired, isPaused,
|
ctx, isLoaded, isPaused, onLoad,
|
||||||
} = containerData;
|
} = containerData;
|
||||||
|
|
||||||
if (onLoad && !isOnLoadFired) {
|
if (!isLoaded || !isPaused) {
|
||||||
containerData.isOnLoadFired = true;
|
ctx.putImageData(imageData, 0, 0);
|
||||||
onLoad();
|
|
||||||
|
|
||||||
ctx.putImageData(imageData, 0, 0); // Always render first frame
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPaused) {
|
if (!isLoaded) {
|
||||||
return;
|
containerData.isLoaded = true;
|
||||||
|
onLoad?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.putImageData(imageData, 0, 0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.prevFrameIndex = frameIndex;
|
this.prevFrameIndex = frameIndex;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user