mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
fix cache with invisble shapes
This commit is contained in:
parent
19de9c40ba
commit
38b2501e4b
@ -198,7 +198,9 @@ export class Shape<
|
|||||||
}
|
}
|
||||||
|
|
||||||
getContext() {
|
getContext() {
|
||||||
Util.warn('shape.getContext() method is deprecated. Please don not use it.');
|
Util.warn(
|
||||||
|
'shape.getContext() method is deprecated. Please don not use it.'
|
||||||
|
);
|
||||||
return this.getLayer().getContext();
|
return this.getLayer().getContext();
|
||||||
}
|
}
|
||||||
getCanvas() {
|
getCanvas() {
|
||||||
@ -575,11 +577,10 @@ export class Shape<
|
|||||||
bufferCanvas,
|
bufferCanvas,
|
||||||
bufferContext;
|
bufferContext;
|
||||||
|
|
||||||
var caching = canvas.isCache;
|
|
||||||
var skipBuffer = canvas.isCache;
|
var skipBuffer = canvas.isCache;
|
||||||
var cachingSelf = top === this;
|
var cachingSelf = top === this;
|
||||||
|
|
||||||
if (!this.isVisible() && !caching) {
|
if (!this.isVisible() && !cachingSelf) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
// if node is cached we just need to draw from cache
|
// if node is cached we just need to draw from cache
|
||||||
|
@ -902,6 +902,42 @@ describe('Caching', function () {
|
|||||||
assert.equal(stage.getIntersection({ x: 150, y: 100 }), rect);
|
assert.equal(stage.getIntersection({ x: 150, y: 100 }), rect);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('check cache for invisible shape', function () {
|
||||||
|
var stage = addStage();
|
||||||
|
|
||||||
|
var layer = new Konva.Layer({
|
||||||
|
// visible: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
var group = new Konva.Group();
|
||||||
|
layer.add(group);
|
||||||
|
|
||||||
|
group.add(
|
||||||
|
new Konva.Rect({
|
||||||
|
x: 50,
|
||||||
|
y: 50,
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
fill: 'red',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
var rect = new Konva.Rect({
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
fill: 'green',
|
||||||
|
visible: false,
|
||||||
|
});
|
||||||
|
group.add(rect);
|
||||||
|
|
||||||
|
stage.add(layer);
|
||||||
|
|
||||||
|
group.cache();
|
||||||
|
layer.draw();
|
||||||
|
cloneAndCompareLayer(layer);
|
||||||
|
});
|
||||||
|
|
||||||
it('even if parent is not listening cache and hit should be created', function () {
|
it('even if parent is not listening cache and hit should be created', function () {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user