Text Animators Expression Selectors not working (since 5.9.0)
bbogge opened this issue · comments
I'm exporting html demo files from bodymovin 5.11.0 After Effects extension and changing the player with cdnjs links
(<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.x.x/lottie.min.js">)
When I apply an expression selector on a text layer's animator, the animation breaks entirely (not even showing, page is completely blank) on every player above 5.9.0 (included).
I'm not sure about it, but it seems that new players lack of some sort of factory or interface for expression selectors, which was present in 5.8.1 (TextExpressionSelectorPropFactory
).
I'm testing on Chrome version 122.0.6261.129 (Official Build) (x86_64)
neither bodymovin 5.12.2 exporter (After Effects extension) seems to fix this
Found the cause of the bug:
TextExpressionSelectorPropFactory
is in fact the missing piece; that's because TextSelectorPropertyDecorator.js
, the file holding the expression selector factory, has not been correctly built since 5.9.0.
For a quick fix on a built player, just copy paste these lines on lottie.js
:
var TextExpressionSelectorPropFactory = (function () { // eslint-disable-line no-unused-vars
function getValueProxy(index, total) {
this.textIndex = index + 1;
this.textTotal = total;
this.v = this.getValue() * this.mult;
return this.v;
}
return function (elem, data) {
this.pv = 1;
this.comp = elem.comp;
this.elem = elem;
this.mult = 0.01;
this.propType = 'textSelector';
this.textTotal = data.totalChars;
this.selectorValue = 100;
this.lastValue = [1, 1, 1];
this.k = true;
this.x = true;
this.getValue = ExpressionManager.initiateExpression.bind(this)(elem, data, this);
this.getMult = getValueProxy;
this.getVelocityAtTime = expressionHelpers.getVelocityAtTime;
if (this.kf) {
this.getValueAtTime = expressionHelpers.getValueAtTime.bind(this);
} else {
this.getValueAtTime = expressionHelpers.getStaticValueAtTime.bind(this);
}
this.setGroupProperty = expressionHelpers.setGroupProperty;
};
}());
var propertyGetTextProp = TextSelectorProp.getTextSelectorProp;
TextSelectorProp.getTextSelectorProp = function (elem, data, arr) {
if (data.t === 1) {
return new TextExpressionSelectorPropFactory(elem, data, arr); // eslint-disable-line no-undef
}
return propertyGetTextProp(elem, data, arr);
};