Lottie-web: Modify time of keyframe

Created on 20 Nov 2019  路  6Comments  路  Source: airbnb/lottie-web

Awesome tool!

Is there a way to shift the time of keyframes dynamically? Inside of after effects I was able to accomplish this with something like valueAtTime(time-2), but is there a way to make that 2 dynamic so that we can provide that value while loading the animation?

Would I have to overwrite a property with something like var $bm_rt;\n$bm_rt = valueAtTime($bm_sub(time, 2));?

Most helpful comment

Hello, maybe reference the 2 as the value of a slider control within AE, rerender with the new expression, and then use lottie-api.js to change the value of this layer.effect on launch?

All 6 comments

Hello, maybe reference the 2 as the value of a slider control within AE, rerender with the new expression, and then use lottie-api.js to change the value of this layer.effect on launch?

Good thinking. I'll give that a try. Thanks!

I'm trying to implement this following the example file:

var mousePosition = [0,0]
animationAPI = lottie_api.createAnimationApi(anim);
var positionProperty = animationAPI.getKeyPath('red_solid,Transform,Position');
animationAPI.addValueCallback(positionProperty, function(currentValue) {
    return mousePosition;
});

I'm not understanding how this is working. Is the property value supposed to change whenever the mousePosition value changes? Also, how does the 'red_solid,Transform,Position' change if the target layer is inside of a preComp? I can't seem to target my property.

Yes, if you update the mousePosition value it will be picked up by the method you are passing to addValueCallback.
Regarding precomps you should add the precomp layer name as part of the path. Something like:
'Precomp Name,red_solid,Transform,Position'

Great, thank you. How do you target a text layer's Source Text property to change the text? I can't seem to get it to work.

Not sure if this is still up to date:

https://github.com/airbnb/lottie-web/wiki/TextLayer.updateDocumentData

There may have been a more recent Issue filing that solved this with an updated solution, I'd search the Issues here too

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ipaulsen picture Ipaulsen  路  4Comments

RenanSgorlom picture RenanSgorlom  路  3Comments

leantide picture leantide  路  3Comments

ochanje210 picture ochanje210  路  3Comments

yannieyeung picture yannieyeung  路  3Comments