mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
fix #93 rather than detecting if a layer is listening or visible, I think it's cleaner to hide and show the buffer canvas along with the scene canvas inside the setVisible method
This commit is contained in:
parent
8cd47db046
commit
0eff286243
4
dist/kinetic-core.js
vendored
4
dist/kinetic-core.js
vendored
@ -2994,7 +2994,6 @@ Kinetic.Stage.prototype = {
|
|||||||
*/
|
*/
|
||||||
for(var n = layers.length - 1; n >= 0; n--) {
|
for(var n = layers.length - 1; n >= 0; n--) {
|
||||||
var layer = layers[n];
|
var layer = layers[n];
|
||||||
if(layer.isVisible() && layer.isListening()) {
|
|
||||||
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
|
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
|
||||||
// this indicates that a buffer pixel may have been found
|
// this indicates that a buffer pixel may have been found
|
||||||
if(p[3] === 255) {
|
if(p[3] === 255) {
|
||||||
@ -3012,7 +3011,6 @@ Kinetic.Stage.prototype = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -3580,9 +3578,11 @@ Kinetic.Layer.prototype = {
|
|||||||
Kinetic.Node.prototype.setVisible.call(this, visible);
|
Kinetic.Node.prototype.setVisible.call(this, visible);
|
||||||
if(visible) {
|
if(visible) {
|
||||||
this.canvas.element.style.display = 'block';
|
this.canvas.element.style.display = 'block';
|
||||||
|
this.bufferCanvas.element.style.display = 'block';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.canvas.element.style.display = 'none';
|
this.canvas.element.style.display = 'none';
|
||||||
|
this.bufferCanvas.element.style.display = 'none';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
moveToTop: function() {
|
moveToTop: function() {
|
||||||
|
6
dist/kinetic-core.min.js
vendored
6
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@ -138,9 +138,11 @@ Kinetic.Layer.prototype = {
|
|||||||
Kinetic.Node.prototype.setVisible.call(this, visible);
|
Kinetic.Node.prototype.setVisible.call(this, visible);
|
||||||
if(visible) {
|
if(visible) {
|
||||||
this.canvas.element.style.display = 'block';
|
this.canvas.element.style.display = 'block';
|
||||||
|
this.bufferCanvas.element.style.display = 'block';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.canvas.element.style.display = 'none';
|
this.canvas.element.style.display = 'none';
|
||||||
|
this.bufferCanvas.element.style.display = 'none';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
moveToTop: function() {
|
moveToTop: function() {
|
||||||
|
@ -368,7 +368,6 @@ Kinetic.Stage.prototype = {
|
|||||||
*/
|
*/
|
||||||
for(var n = layers.length - 1; n >= 0; n--) {
|
for(var n = layers.length - 1; n >= 0; n--) {
|
||||||
var layer = layers[n];
|
var layer = layers[n];
|
||||||
if(layer.isVisible() && layer.isListening()) {
|
|
||||||
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
|
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
|
||||||
// this indicates that a buffer pixel may have been found
|
// this indicates that a buffer pixel may have been found
|
||||||
if(p[3] === 255) {
|
if(p[3] === 255) {
|
||||||
@ -386,7 +385,6 @@ Kinetic.Stage.prototype = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user