Skip to content

Commit

Permalink
Fix scaling issues that involves width/height (fabricjs#4491)
Browse files Browse the repository at this point in the history
* fixed
* added a small test
* typo
  • Loading branch information
asturur authored Nov 23, 2017
1 parent 5c02dfd commit 6b89bfa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mixins/object_geometry.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@
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.flipX + sep + this.flipY;
sep + this.skewX + sep + this.skewY + sep + this.angle + sep + this.flipX + sep + this.flipY +
sep + this.width + sep + this.height;
},

/**
Expand Down
17 changes: 17 additions & 0 deletions test/unit/object_geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,23 @@
assert.ok(cObj.isOnScreen(), 'zooming out the object is again on screen');
});

QUnit.test('transformMatrixKey depends from properties', function(assert) {
var cObj = new fabric.Object(
{ left: -10, top: -10, width: 30, height: 40, strokeWidth: 0});
var key1 = cObj.transformMatrixKey();
cObj.left = 5;
var key2 = cObj.transformMatrixKey();
cObj.left = -10;
var key3 = cObj.transformMatrixKey();
cObj.width = 5;
var key4 = cObj.transformMatrixKey();
assert.notEqual(key1, key2, 'keys are different');
assert.equal(key1, key3, 'keys are equal');
assert.notEqual(key4, key2, 'keys are different');
assert.notEqual(key4, key1, 'keys are different');
assert.notEqual(key4, key3, 'keys are different');
});

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 6b89bfa

Please sign in to comment.