Merge pull request #773 from lwallent/master

Fixed zero bounds children resulting in NaN group bounds.
This commit is contained in:
Anton Lavrenov 2019-10-23 10:19:09 -05:00 committed by GitHub
commit 5f7b6f86c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -507,8 +507,7 @@ export abstract class Container<ChildType extends Node> extends Node<
break;
}
}
if (hasVisible) {
if (hasVisible && minX !== undefined) {
selfRect = {
x: minX,
y: minY,

View File

@ -2207,7 +2207,21 @@ suite('Container', function() {
'layer has exactly three children'
);
});
test('getClientRect - adding a zero bounds shape should result in zero bounds', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var grp = new Konva.Group();
var zeroRect = new Konva.Rect({x: 0, y: 0, width: 0, height: 0});
grp.add(zeroRect);
var bounds = grp.getClientRect();
assert.deepEqual(bounds, {
x: 0,
y: 0,
width: 0,
height: 0
});
});
test('getClientRect - test empty case', function() {
var stage = addStage();
var layer = new Konva.Layer();