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:
ericdrowell 2012-10-02 23:33:53 -07:00
parent 8cd47db046
commit 0eff286243
4 changed files with 41 additions and 41 deletions

View File

@ -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() {

File diff suppressed because one or more lines are too long

View File

@ -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() {

View File

@ -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;
}, },