Possible to update textlayers?
See original GitHub issueHi,
Im trying to update the text in a textlayer after I have created the element with bodymovin.loadAnimation. If I try to simply update the animationData-object on the animation, it wont update. I can see that the object in developertools is updated, but this will not cause a rerender of the text onscreen. I have also tried to destroy the animation and recreate the object, but this wont work ether. So this will not work to update text, only to set it initially before calling loadAnimation:
anim.animationData.layers[0].t.d.k[0].s.t = 'RandomText';
I can see that you are doing something similar in this example on Codepen, and I can recreate your example locally. But I still cant update the text of my composition. Is there anything special about text? The text is exported from AE as text and not shapes.
I can give more complex code examples if needed.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10

Top Related StackOverflow Question
@ssanthos @christianeide I’ve added a method “updateDocumentData” that allows updating text during animation. More here https://github.com/bodymovin/bodymovin/wiki/TextLayer.updateDocumentData
Just a little more info on this for people still struggling (like I was)
updateDocumentData()works, but needs to be called on anTextElement, so instead ofanimData.layers[n].layers[m].t.d.k[0].s.tInstead, look at the renderer’s elements arrayse.g.
anim.renderer.elements[0].elements[4].updateDocumentData({t:"BOB"})It helps to use the console and dig throughanim.renderer.elements[n]to make sure you’re calling it on aTextElement(in my caseSVGTextElementbecause I’m using the SVG renderer.NOTE: You won’t see the effect until you next render a frame (which is automatic if your anim is playing), if not you can call
anim.renderer.renderFrame(frameNumber)to force it, however, it still won’t update if you’re already on that frame, so choose a different one.