Fix scaling issues that involves width/height (#4491)

* fixed
* added a small test
* typo
This commit is contained in:
Andrea Bogazzi 2017-11-23 18:04:54 +01:00 committed by GitHub
parent 91de6d078d
commit a9d2fb1ba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -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;
},
/**

View file

@ -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});