From 90bfc8a29af9b02c2efab3be913deedddb20c14c Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 4 Jul 2021 12:46:04 +0200 Subject: [PATCH] fix unnecessary invalidation --- src/shapes/object.class.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 62b38bc57c1..735fa740871 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -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) }; },