Closed orenlwsc closed 6 months ago
hi, is the animation playing when the updateDocumentData
is called? If it is paused it will not update until it renders again
@bodymovin actually, no, I'm stopping it, updating, then playing it again. check out the following snippet:
const reRender = () => {
// This is a workaround since in Lottie, while updating text layers on paused animations,
// rendering isn't occur, and the updated parameters will not be shown until seek to other frame
// https://github.com/airbnb/lottie-web/issues/2297
if (lottieInstance.lottie) {
lottieInstance.lottie.stop()
const { currentFrame, totalFrames } = lottieInstance.lottie
const frameToJumpTo = totalFrames > currentFrame ? currentFrame + 1 : currentFrame - 1
lottieInstance.lottie.goToAndStop(frameToJumpTo, true)
lottieInstance.lottie.goToAndStop(currentFrame, true)
lottieInstance.lottie.play()
}
}
also, I tried it without playing again (aka the last line in the snippet) - when I'm not playing it, nothing gets updated at all, which is expected behavior.
so using that snippet it is not working?
so using that snippet it is not working?
@bodymovin nope. I'm suspecting it might be related to the animation file itself. if you have any insights or ideas to share with me, would love to hear any possible direction.
Edit
Turns out I was right. When a text gets an attribute with an expression, theupdateDocumentData
not works perfectly.
Here the problem:
"t":{
"d":{
"k":[
{
"s":{
"sz":[
1182,
1075
],
"ps":[
-525.5,
-171.398193359375
],
"s":150,
"f":"Arial-BoldMT",
"t":"TEXT 2",
"ca":1,
"j":2,
"tr":20,
"lh":180,
"ls":0,
"fc":[
0.13,
0.142,
0.188
]
},
"t":0
}
],
"x":"var $bm_rt;\n$bm_rt = text.sourceText;" <==== when removed, the update works properly
},
...,
...,
Is that a bug? expected behavior? any proper workaround for such cases?
Edit 2: Is it possible to apply something similar to updateDocumentData
on general objects and attributes such as position, rotation, etc?
Hello,
I'm trying to use the updateDocumentData API to update text elements. Currently, passing
t
in the payload updates the text correctly and properly triggers the re-rendering. However, when passing other attributes likes
for font size andj
for justifying, the values are updated correctly, but the animation does not update.I made sure that:
s
andj
receiving number values and not string values (but I tried strings anyway, just to make sure)Currently, my workaround is to work directly on the JSON. When I manually update the JSON object by finding the relevant elements, it correctly updates both values and renders. However, the amination flicker and its behavior I prefer to avoid.
Is there another way to get the values updated without flickering the animation? Am I missing something when using the
updateDocumentData
?Thanks!