cache fix

This commit is contained in:
Anton Lavrenov
2019-02-22 22:13:37 -05:00
parent 010800dba4
commit 605725fe43
4 changed files with 37 additions and 4 deletions

View File

@@ -1095,4 +1095,35 @@ suite('Caching', function() {
assert.equal(stage.getIntersection({ x: 5, y: 20 }), bg);
assert.equal(stage.getIntersection({ x: 55, y: 20 }), rect);
});
it('recache should update internal caching', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var bigCircle = new Konva.Circle({
x: 100,
y: 100,
radius: 100,
fill: 'red',
draggable: true
});
layer.add(bigCircle);
bigCircle.cache();
layer.draw();
var d = layer.getContext().getImageData(100, 100, 1, 1).data;
assert.equal(d[0], 255, 'see red');
bigCircle.fill('blue');
bigCircle.cache();
layer.draw();
d = layer.getContext().getImageData(100, 100, 1, 1).data;
assert.equal(d[0], 0, 'no red');
assert.equal(d[2], 255, 'see blue');
});
});