mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 19:07:59 +08:00
Better calculations for container.getClientRect()
This commit is contained in:
@@ -928,7 +928,11 @@ suite('Container', function() {
|
||||
assert.equal(layer.find('Shape').length, 2, 'layer should have 2 shapes');
|
||||
assert.equal(layer.find('Layer').length, 0, 'layer should have 0 layers');
|
||||
|
||||
assert.equal(layer.find('Group, Rect').length, 3, 'layer should have 3 [group or rects]');
|
||||
assert.equal(
|
||||
layer.find('Group, Rect').length,
|
||||
3,
|
||||
'layer should have 3 [group or rects]'
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
fooLayer.find('Group').length,
|
||||
@@ -2333,6 +2337,49 @@ suite('Container', function() {
|
||||
});
|
||||
});
|
||||
|
||||
test('getClientRect - test group with visible child inside invisible parent', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer({
|
||||
visible: false
|
||||
});
|
||||
stage.add(layer);
|
||||
var group = new Konva.Group({
|
||||
x: 10,
|
||||
y: 10
|
||||
});
|
||||
layer.add(group);
|
||||
|
||||
var subGroup = new Konva.Group({
|
||||
visible: false
|
||||
});
|
||||
group.add(subGroup);
|
||||
subGroup.add(
|
||||
new Konva.Rect({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 50,
|
||||
height: 50,
|
||||
visible: true
|
||||
})
|
||||
);
|
||||
subGroup.add(
|
||||
new Konva.Rect({
|
||||
x: 400,
|
||||
y: 400,
|
||||
width: 50,
|
||||
height: 50,
|
||||
visible: true
|
||||
})
|
||||
);
|
||||
layer.draw();
|
||||
assert.deepEqual(group.getClientRect(), {
|
||||
x: 10,
|
||||
y: 10,
|
||||
width: 0,
|
||||
height: 0
|
||||
});
|
||||
});
|
||||
|
||||
test('get client rect with deep nested hidden shape 2', function() {
|
||||
var layer = new Konva.Layer();
|
||||
var group = new Konva.Group({
|
||||
|
Reference in New Issue
Block a user