Skip to content

Commit

Permalink
fix(fabric.Object) unnecessary cache invalidation, ISSUE-7157 (#7183)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Jul 4, 2021
1 parent 0f13f2d commit 8d790e9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,17 @@
* @return {Object} object with scaleX and scaleY properties
*/
getObjectScaling: function() {
// if the object is a top level one, on the canvas, we go for simple aritmetic
// otherwise the complex method with angles will return approximations and decimals
// and will likely kill the cache when not needed
// https://github.com/fabricjs/fabric.js/issues/7157
if (!this.group) {
return {
scaleX: this.scaleX,
scaleY: this.scaleY,
};
}
// if we are inside a group total zoom calculation is complex, we defer to generic matrices
var options = fabric.util.qrDecompose(this.calcTransformMatrix());
return { scaleX: Math.abs(options.scaleX), scaleY: Math.abs(options.scaleY) };
},
Expand Down

0 comments on commit 8d790e9

Please sign in to comment.