Skip to content

Commit

Permalink
Fix originX and originY missing in the matrix cacheKey (fabricjs#4703)
Browse files Browse the repository at this point in the history
* added test
* fixed the typo
  • Loading branch information
asturur authored Feb 10, 2018
1 parent e092ae6 commit b1e04d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mixins/object_geometry.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
* Returns coordinates of object's bounding rectangle (left, top, width, height)
* the box is intented as aligned to axis of canvas.
* @param {Boolean} [absolute] use coordinates without viewportTransform
* @param {Boolean} [calculate] use coordinates of current position instead of .oCoords
* @param {Boolean} [calculate] use coordinates of current position instead of .oCoords / .aCoords
* @return {Object} Object with left, top, width, height properties
*/
getBoundingRect: function(absolute, calculate) {
Expand Down Expand Up @@ -453,7 +453,7 @@
prefix = this.group.transformMatrixKey(skipGroup) + sep;
};
return prefix + this.top + sep + this.left + sep + this.scaleX + sep + this.scaleY +
sep + this.skewX + sep + this.skewY + sep + this.angle +
sep + this.skewX + sep + this.skewY + sep + this.angle + sep + this.originX + sep + this.originY +
sep + this.width + sep + this.height + sep + this.strokeWidth + this.flipX + this.flipY;
},

Expand Down
13 changes: 13 additions & 0 deletions test/unit/object_geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,19 @@
assert.notEqual(key4, key3, 'keys are different');
});

QUnit.test('transformMatrixKey depends from originX/originY', function(assert) {
var cObj = new fabric.Object(
{ left: -10, top: -10, width: 30, height: 40, strokeWidth: 0, originX: 'left', originY: 'top' });
var key1 = cObj.transformMatrixKey();
cObj.originX = 'center';
var key2 = cObj.transformMatrixKey();
cObj.originY = 'center';
var key3 = cObj.transformMatrixKey();
assert.notEqual(key1, key2, 'keys are different origins 1');
assert.notEqual(key1, key3, 'keys are different origins 2');
assert.notEqual(key2, key3, 'keys are different origins 3');
});

QUnit.test('isOnScreen with object that include canvas', function(assert) {
var cObj = new fabric.Object(
{ left: -10, top: -10, width: canvas.getWidth() + 100, height: canvas.getHeight(), strokeWidth: 0});
Expand Down

0 comments on commit b1e04d1

Please sign in to comment.