mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
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:
parent
0dc51c2239
commit
2b62eb5cfa
2 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue