fixed stage.hide() bug, created new isVisible() method, and moved visible check to container

This commit is contained in:
Eric Rowell
2012-04-14 12:04:45 -07:00
parent c17029d38e
commit 3a520376e5
7 changed files with 125 additions and 74 deletions

11
dist/kinetic-core.js vendored
View File

@@ -327,6 +327,12 @@ Kinetic.Node.prototype = {
}
}
},
/**
* determine if shape is visible or not
*/
isVisible: function() {
return this.attrs.visible;
},
/**
* show node
*/
@@ -1032,10 +1038,11 @@ Kinetic.Container.prototype = {
* draw children
*/
_drawChildren: function() {
var stage = this.getStage();
var children = this.children;
for(var n = 0; n < children.length; n++) {
var child = children[n];
if(child.nodeType === 'Shape') {
if(child.nodeType === 'Shape' && child.isVisible() && stage.isVisible()) {
child._draw(child.getLayer());
}
else {
@@ -2281,7 +2288,7 @@ Kinetic.Shape.prototype = {
* @param {Layer} layer Layer that the shape will be drawn on
*/
_draw: function(layer) {
if(this.attrs.visible && this.drawFunc !== undefined) {
if(layer !== undefined && this.drawFunc !== undefined) {
var stage = layer.getStage();
var context = layer.getContext();
var family = [];

File diff suppressed because one or more lines are too long