mirror of
https://github.com/konvajs/konva.git
synced 2026-01-09 11:34:38 +08:00
fix recache bug
This commit is contained in:
@@ -208,8 +208,7 @@ export abstract class Node {
|
|||||||
*/
|
*/
|
||||||
clearCache() {
|
clearCache() {
|
||||||
this._cache.delete(CANVAS);
|
this._cache.delete(CANVAS);
|
||||||
this._filterUpToDate = false;
|
this._clearSelfAndDescendantCache();
|
||||||
this._clearSelfAndDescendantCache(undefined);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -313,7 +312,7 @@ export abstract class Node {
|
|||||||
cachedHitCanvas.isCache = true;
|
cachedHitCanvas.isCache = true;
|
||||||
|
|
||||||
this._cache.delete('canvas');
|
this._cache.delete('canvas');
|
||||||
// this.clearCache();
|
this._filterUpToDate = false;
|
||||||
|
|
||||||
sceneContext.save();
|
sceneContext.save();
|
||||||
hitContext.save();
|
hitContext.save();
|
||||||
|
|||||||
@@ -1126,4 +1126,32 @@ suite('Caching', function() {
|
|||||||
assert.equal(d[0], 0, 'no red');
|
assert.equal(d[0], 0, 'no red');
|
||||||
assert.equal(d[2], 255, 'see blue');
|
assert.equal(d[2], 255, 'see blue');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('recache with filters', 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.filters([Konva.Filters.Blur]);
|
||||||
|
bigCircle.blurRadius(10);
|
||||||
|
bigCircle.cache();
|
||||||
|
|
||||||
|
layer.draw();
|
||||||
|
bigCircle.cache();
|
||||||
|
|
||||||
|
layer.draw();
|
||||||
|
|
||||||
|
var d = layer.getContext().getImageData(100, 100, 1, 1).data;
|
||||||
|
assert.equal(d[0], 255, 'see red');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user