Fix wrong internal caching of absolute attributes. fix #843

This commit is contained in:
Anton Lavrenov
2020-02-10 08:22:07 -05:00
parent 2634bbbf89
commit 86f847a702
6 changed files with 70 additions and 15 deletions

View File

@@ -3783,4 +3783,47 @@ suite('Node', function() {
assert.equal(callCount, 2);
Konva.Util.warn = oldWarn;
});
test('check transform caching', function() {
var stage = addStage();
var layer = new Konva.Layer();
var rect = new Konva.Rect({
x: 50,
y: 50,
width: 150,
height: 50,
stroke: 'black',
strokeWidth: 4
});
var text00 = new Konva.Text({
text: 'Sample text',
x: 50,
y: 50,
fontSize: 20
});
layer.add(rect);
layer.add(text00);
stage.add(layer);
stage.x(+40);
stage.y(+40);
stage.draw();
layer.removeChildren();
text00.getClientRect({}); // Commenting this line or putting it after line 41 puts text in rectangle
layer.add(text00);
layer.add(rect);
stage.draw();
assert.equal(text00.getClientRect().x, 90);
assert.equal(text00.getClientRect().y, 90);
});
});