mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
fix cache bug
This commit is contained in:
parent
9fcb6b4ae8
commit
1f9ce30d81
@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
### Fixed
|
||||
- Correct calculation in `getClientRect` method of `Konva.Line` and `Konva.Container`.
|
||||
- Correct `toObject()` behaviour for node with attrs with extended native prototypes
|
||||
- Fixed bug for caching where buffer canvas is required
|
||||
|
||||
### Changed
|
||||
- Dragging now works much better. If your pointer is out of stage content dragging will still continue.
|
||||
|
12
konva.js
12
konva.js
@ -3,7 +3,7 @@
|
||||
* Konva JavaScript Framework v0.9.9
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT or GPL Version 2 licenses.
|
||||
* Date: Sat Sep 12 2015
|
||||
* Date: Sat Sep 19 2015
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
|
||||
@ -6739,7 +6739,7 @@ var Konva = {};
|
||||
context.restore();
|
||||
}
|
||||
else {
|
||||
this._drawChildren(canvas, 'drawScene', top);
|
||||
this._drawChildren(canvas, 'drawScene', top, false, caching);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@ -6767,7 +6767,7 @@ var Konva = {};
|
||||
}
|
||||
return this;
|
||||
},
|
||||
_drawChildren: function(canvas, drawMethod, top) {
|
||||
_drawChildren: function(canvas, drawMethod, top, caching, skipBuffer) {
|
||||
var layer = this.getLayer(),
|
||||
context = canvas && canvas.getContext(),
|
||||
clipWidth = this.getClipWidth(),
|
||||
@ -6788,7 +6788,7 @@ var Konva = {};
|
||||
}
|
||||
|
||||
this.children.each(function(child) {
|
||||
child[drawMethod](canvas, top);
|
||||
child[drawMethod](canvas, top, caching, skipBuffer);
|
||||
});
|
||||
|
||||
if (hasClip) {
|
||||
@ -7250,7 +7250,7 @@ var Konva = {};
|
||||
}
|
||||
return rect;
|
||||
},
|
||||
drawScene: function(can, top, caching) {
|
||||
drawScene: function(can, top, caching, skipBuffer) {
|
||||
var layer = this.getLayer(),
|
||||
canvas = can || layer.getCanvas(),
|
||||
context = canvas.getContext(),
|
||||
@ -7275,7 +7275,7 @@ var Konva = {};
|
||||
}
|
||||
context.save();
|
||||
// if buffer canvas is needed
|
||||
if (this._useBufferCanvas(caching)) {
|
||||
if (this._useBufferCanvas(caching) && !skipBuffer) {
|
||||
stage = this.getStage();
|
||||
bufferCanvas = stage.bufferCanvas;
|
||||
bufferContext = bufferCanvas.getContext();
|
||||
|
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -345,7 +345,7 @@
|
||||
context.restore();
|
||||
}
|
||||
else {
|
||||
this._drawChildren(canvas, 'drawScene', top);
|
||||
this._drawChildren(canvas, 'drawScene', top, false, caching);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@ -373,7 +373,7 @@
|
||||
}
|
||||
return this;
|
||||
},
|
||||
_drawChildren: function(canvas, drawMethod, top) {
|
||||
_drawChildren: function(canvas, drawMethod, top, caching, skipBuffer) {
|
||||
var layer = this.getLayer(),
|
||||
context = canvas && canvas.getContext(),
|
||||
clipWidth = this.getClipWidth(),
|
||||
@ -394,7 +394,7 @@
|
||||
}
|
||||
|
||||
this.children.each(function(child) {
|
||||
child[drawMethod](canvas, top);
|
||||
child[drawMethod](canvas, top, caching, skipBuffer);
|
||||
});
|
||||
|
||||
if (hasClip) {
|
||||
|
@ -233,7 +233,7 @@
|
||||
}
|
||||
return rect;
|
||||
},
|
||||
drawScene: function(can, top, caching) {
|
||||
drawScene: function(can, top, caching, skipBuffer) {
|
||||
var layer = this.getLayer(),
|
||||
canvas = can || layer.getCanvas(),
|
||||
context = canvas.getContext(),
|
||||
@ -258,7 +258,7 @@
|
||||
}
|
||||
context.save();
|
||||
// if buffer canvas is needed
|
||||
if (this._useBufferCanvas(caching)) {
|
||||
if (this._useBufferCanvas(caching) && !skipBuffer) {
|
||||
stage = this.getStage();
|
||||
bufferCanvas = stage.bufferCanvas;
|
||||
bufferContext = bufferCanvas.getContext();
|
||||
|
@ -710,4 +710,35 @@ suite('Caching', function() {
|
||||
layer.draw();
|
||||
cloneAndCompareLayer(layer, 150);
|
||||
});
|
||||
|
||||
test('test group with circle + buffer canvas usage', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
|
||||
var group = new Konva.Group({
|
||||
x: 100,
|
||||
y: 100,
|
||||
draggable: true
|
||||
});
|
||||
layer.add(group);
|
||||
|
||||
var circle = new Konva.Circle({
|
||||
radius: 10,
|
||||
// fill: 'white',
|
||||
fillRadialGradientStartPoint: 0,
|
||||
fillRadialGradientStartRadius: 0,
|
||||
fillRadialGradientEndPoint: 0,
|
||||
fillRadialGradientEndRadius: 10,
|
||||
fillRadialGradientColorStops: [0, 'red', 0.5, 'yellow', 1, 'blue'],
|
||||
opacity: 0.4,
|
||||
strokeHitEnabled: false,
|
||||
stroke: 'rgba(0,0,0,0)'
|
||||
});
|
||||
group.add(circle);
|
||||
group.cache();
|
||||
stage.draw();
|
||||
|
||||
cloneAndCompareLayer(layer, 150);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user