Fix shape bounds when passing position in constructor (#1708)

In some special circumstances, when position was passed in constructor
and when position key was before size key, bounds were wrongly
calculated.
This ensure that when size is set, even the first time, bounds are
properly recalculated.
Closes #1686
This commit is contained in:
Samuel Asensi 2019-12-15 14:31:31 +01:00 committed by Jürg Lehni
parent 0dc51c2239
commit 2b62eb5cfa
2 changed files with 9 additions and 1 deletions

View file

@ -101,8 +101,8 @@ var Shape = Item.extend(/** @lends Shape# */{
this._radius._set(width / 2, height / 2);
}
this._size._set(width, height);
this._changed(/*#=*/Change.GEOMETRY);
}
this._changed(/*#=*/Change.GEOMETRY);
},
/**

View file

@ -54,6 +54,14 @@ test('shape.toPath().toShape()', function() {
});
});
test('new Shape.Rectangle() with position set before size', function() {
var shape1 = new Shape.Rectangle({
position: [0, 0],
size: new Size(100, 100)
});
equals(shape1.bounds.width, 100);
});
test('Shape.Rectangle radius works with negative size', function() {
var shape = new Shape.Rectangle({
center: [50, 50],