Skip to content

Commit

Permalink
caching object property reference
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymovin committed Apr 7, 2018
1 parent afaa0a6 commit c4eef93
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion player/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
//elem.style.display = 'none';
var animData = {
container: elem,
renderer: 'canvas',
renderer: 'svg',
loop: true,
autoplay: true,
rendererSettings: {
Expand Down
3 changes: 2 additions & 1 deletion player/js/3rd_party/transformation-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ var Matrix = (function(){
if(this.isIdentity()) {
return x + ',' + y;
}
return (x * this.props[0] + y * this.props[4] + this.props[12])+','+(x * this.props[1] + y * this.props[5] + this.props[13]);
var _p = this.props;
return (x * _p[0] + y * _p[4] + _p[12])+','+(x * _p[1] + y * _p[5] + _p[13]);
}

function toCSS() {
Expand Down
18 changes: 9 additions & 9 deletions player/js/elements/ShapeElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ IShapeElement.prototype = {
this.prepareProperties(num, this.isInRange);
},
buildShapeString: function(pathNodes, length, closed, mat) {
var i, shapeString = '';
for(i = 1; i < length; i += 1) {
if (i === 1) {
shapeString += " M" + mat.applyToPointStringified(pathNodes.v[0][0], pathNodes.v[0][1]);
}
shapeString += " C" + mat.applyToPointStringified(pathNodes.o[i - 1][0], pathNodes.o[i - 1][1]) + " " + mat.applyToPointStringified(pathNodes.i[i][0], pathNodes.i[i][1]) + " " + mat.applyToPointStringified(pathNodes.v[i][0], pathNodes.v[i][1]);
if(length === 0) {
return '';
}
if (length === 1) {
shapeString += " M" + mat.applyToPointStringified(pathNodes.v[0][0], pathNodes.v[0][1]);
var _o = pathNodes.o;
var _i = pathNodes.i;
var _v = pathNodes.v;
var i, shapeString = " M" + mat.applyToPointStringified(_v[0][0], _v[0][1]);
for(i = 1; i < length; i += 1) {
shapeString += " C" + mat.applyToPointStringified(_o[i - 1][0], _o[i - 1][1]) + " " + mat.applyToPointStringified(_i[i][0], _i[i][1]) + " " + mat.applyToPointStringified(_v[i][0], _v[i][1]);
}
if (closed && length) {
shapeString += " C" + mat.applyToPointStringified(pathNodes.o[i - 1][0], pathNodes.o[i - 1][1]) + " " + mat.applyToPointStringified(pathNodes.i[0][0], pathNodes.i[0][1]) + " " + mat.applyToPointStringified(pathNodes.v[0][0], pathNodes.v[0][1]);
shapeString += " C" + mat.applyToPointStringified(_o[i - 1][0], _o[i - 1][1]) + " " + mat.applyToPointStringified(_i[0][0], _i[0][1]) + " " + mat.applyToPointStringified(_v[0][0], _v[0][1]);
shapeString += 'z';
}
return shapeString;
Expand Down

0 comments on commit c4eef93

Please sign in to comment.