Skip to content

Commit

Permalink
Merge pull request #2833 from mbasaglia/toggle_expressions
Browse files Browse the repository at this point in the history
Add renderer config that disables expressions
  • Loading branch information
bodymovin authored Aug 14, 2022
2 parents b90bfd5 + 745f162 commit 8455c07
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions player/js/renderers/CanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function CanvasRenderer(animationItem, config) {
contentVisibility: (config && config.contentVisibility) || 'visible',
className: (config && config.className) || '',
id: (config && config.id) || '',
runExpressions: !config || config.runExpressions === undefined || config.runExpressions,
};
this.renderConfig.dpr = (config && config.dpr) || 1;
if (this.animationItem.wrapper) {
Expand Down
1 change: 1 addition & 0 deletions player/js/renderers/HybridRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function HybridRenderer(animationItem, config) {
x: (config && config.filterSize && config.filterSize.x) || '-100%',
y: (config && config.filterSize && config.filterSize.y) || '-100%',
},
runExpressions: !config || config.runExpressions === undefined || config.runExpressions,
};
this.globalData = {
_mdf: false,
Expand Down
1 change: 1 addition & 0 deletions player/js/renderers/SVGRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function SVGRenderer(animationItem, config) {
},
width: (config && config.width),
height: (config && config.height),
runExpressions: !config || config.runExpressions === undefined || config.runExpressions,
};

this.globalData = {
Expand Down
9 changes: 9 additions & 0 deletions player/js/utils/expressions/ExpressionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ const ExpressionManager = (function () {
}

function initiateExpression(elem, data, property) {
// Bail out if we don't want expressions
function noOp(_value) {
return _value;
}
if (!elem.globalData.renderConfig.runExpressions) {
return noOp;
}

var val = data.x;
var needsVelocity = /velocity(?![\w\d])/.test(val);
var _needsRandom = val.indexOf('random') !== -1;
Expand Down Expand Up @@ -666,6 +674,7 @@ const ExpressionManager = (function () {
var parent;
var randSeed = Math.floor(Math.random() * 1000000);
var globalData = elem.globalData;

function executeExpression(_value) {
// globalData.pushExpression();
value = _value;
Expand Down

0 comments on commit 8455c07

Please sign in to comment.