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--) {
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;
// this indicates that a buffer pixel may have been found
if(p[3] === 255) {
@ -3012,7 +3011,6 @@ Kinetic.Stage.prototype = {
};
}
}
}
return null;
},
@ -3580,9 +3578,11 @@ Kinetic.Layer.prototype = {
Kinetic.Node.prototype.setVisible.call(this, visible);
if(visible) {
this.canvas.element.style.display = 'block';
this.bufferCanvas.element.style.display = 'block';
}
else {
this.canvas.element.style.display = 'none';
this.bufferCanvas.element.style.display = 'none';
}
},
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);
if(visible) {
this.canvas.element.style.display = 'block';
this.bufferCanvas.element.style.display = 'block';
}
else {
this.canvas.element.style.display = 'none';
this.bufferCanvas.element.style.display = 'none';
}
},
moveToTop: function() {

View File

@ -368,7 +368,6 @@ Kinetic.Stage.prototype = {
*/
for(var n = layers.length - 1; n >= 0; 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;
// this indicates that a buffer pixel may have been found
if(p[3] === 255) {
@ -386,7 +385,6 @@ Kinetic.Stage.prototype = {
};
}
}
}
return null;
},