garbage collecting empty arrays in _removeName method to free up space

This commit is contained in:
Eric Rowell
2012-06-02 00:39:17 -07:00
parent 1b333bc800
commit 9f243d4a2e
5 changed files with 45 additions and 25 deletions

View File

@@ -264,20 +264,27 @@ Kinetic.Shape.prototype = {
context.lineJoin = this.attrs.lineJoin;
}
},
/**
* apply shadow. return true if shadow was applied
* and false if it was not
*/
_applyShadow: function() {
var context = this.getContext();
var s = this.attrs.shadow;
var aa = this.getAbsoluteAlpha();
var sa = this.attrs.shadow.alpha;
if(s.color !== undefined) {
context.globalAlpha = sa * aa;
context.shadowColor = s.color;
context.shadowBlur = s.blur;
context.shadowOffsetX = s.offset.x;
context.shadowOffsetY = s.offset.y;
this.appliedShadow = true;
return true;
if(s !== undefined) {
var aa = this.getAbsoluteAlpha();
var sa = this.attrs.shadow.alpha;
if(sa !== undefined && s.color !== undefined) {
context.globalAlpha = sa * aa;
context.shadowColor = s.color;
context.shadowBlur = s.blur;
context.shadowOffsetX = s.offset.x;
context.shadowOffsetY = s.offset.y;
this.appliedShadow = true;
return true;
}
}
return false;

View File

@@ -493,7 +493,7 @@ Kinetic.Stage.prototype = {
return true;
}
else if(!isDragging && this.touchMove) {
else if(!isDragging && this.touchMove) {
shape._handleEvents('touchmove', evt);
return true;
}
@@ -938,6 +938,9 @@ Kinetic.Stage.prototype = {
nodes.splice(n, 1);
}
}
if(nodes.length === 0) {
this.names[node.attrs.name] = undefined;
}
}
}
},