Closed sni-J closed 4 months ago
Thanks @sni-J for the detailed issue and suggestions.
I agree with you; the IntersectionObserver callback shouldn't get debounced. We will address this issue promptly in the next release.
Your suggestion for disableFreezeOnInvisible
makes sense as well. Also, it shouldn't be the responsibility of the dotlottie-react to handle this. We can move this partial rendering behavior to the dotlottie-web main animation loop instead of on each frame event. This change would ensure that if the animation is running at a low FPS, the partial rendering is not coupled with the animation speed. For example, I think this adjustment should fix the issue where fast scrolling can cause the animation to appear clipped.
Even the offscreen performance optimization, I think, should be handled and live in the core dotlottie-web.
For now, we will:
disableFreezeOnInvisible
propOther improvements will be addressed in the future.
@sni-J, as a workaround for now, you may listen for the freeze event and immediately unfreeze when it occurs:
<DotLottieReact
dotLottieRefCallback={(dotLottie) => {
dotLottie?.addEventListener("freeze", () => {
dotLottie?.unfreeze();
});
}}
src="https://lottie.host/63e43fb7-61be-486f-aef2-622b144f7fc1/2m8UGcP8KR.json"
loop
autoplay
style={{
maxWidth: "600px"
}}
/>
@sni-J debounce has been removed on dotlottie-react v0.7.1
@sni-J partial canvas rendering has been temporarily disabled in dotlottie-react v0.8.3. This feature will be ported to dotlottie-web in a future release, with a configuration option to disable the optimization if needed.
This should resolve your issue. Let me know if you're facing any other problems. Thanks!
Overview
https://codepen.io/sni-J/pen/VwOopGY
forked from Getting Started, just added 100vh div above DotLottieReact
150ms is not very long but lottie coming out of empty space is quite awkward.
Reason
So, it acts like this...
Initial (placed outside of viewport, or !intersecting in IntersectionObserver word)
Become visible (intersecting: false -> true):
Become invisible (intersecting: true -> false):
(Repeat)
Solution Suggestion
Remove debounce IntersectionObserver won't need debounce in most case IMO
disableFreezeOnInvisible
I have no idea how heavy eachdraw
is, but maybe this can cover lots of simple casesor any other better solutions
Workaround based on current implementation
Labels
Type: Bug
label to this issue.