From 9f8fe22f3ced4f18e89b9b32bc31f806433ac4d0 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 2 Nov 2022 02:43:39 +0100 Subject: [PATCH] RLottie: Fix redundant render --- src/lib/rlottie/RLottie.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/lib/rlottie/RLottie.ts b/src/lib/rlottie/RLottie.ts index 382d356ee..e3df57966 100644 --- a/src/lib/rlottie/RLottie.ts +++ b/src/lib/rlottie/RLottie.ts @@ -39,9 +39,9 @@ class RLottie { private containers = new Map(); private imgSize!: number; @@ -372,21 +372,17 @@ class RLottie { this.containers.forEach((containerData) => { const { - ctx, onLoad, isOnLoadFired, isPaused, + ctx, isLoaded, isPaused, onLoad, } = containerData; - if (onLoad && !isOnLoadFired) { - containerData.isOnLoadFired = true; - onLoad(); - - ctx.putImageData(imageData, 0, 0); // Always render first frame + if (!isLoaded || !isPaused) { + ctx.putImageData(imageData, 0, 0); } - if (isPaused) { - return; + if (!isLoaded) { + containerData.isLoaded = true; + onLoad?.(); } - - ctx.putImageData(imageData, 0, 0); }); this.prevFrameIndex = frameIndex;