mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 10:47:59 +08:00
garbage collecting empty arrays in _removeName method to free up space
This commit is contained in:
32
dist/kinetic-core.js
vendored
32
dist/kinetic-core.js
vendored
@@ -1971,7 +1971,7 @@ Kinetic.Stage.prototype = {
|
||||
return true;
|
||||
}
|
||||
|
||||
else if(!isDragging && this.touchMove) {
|
||||
else if(!isDragging && this.touchMove) {
|
||||
shape._handleEvents('touchmove', evt);
|
||||
return true;
|
||||
}
|
||||
@@ -2416,6 +2416,9 @@ Kinetic.Stage.prototype = {
|
||||
nodes.splice(n, 1);
|
||||
}
|
||||
}
|
||||
if(nodes.length === 0) {
|
||||
this.names[node.attrs.name] = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2911,20 +2914,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;
|
||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
27
src/Shape.js
27
src/Shape.js
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@@ -581,7 +581,7 @@ Test.prototype.tests = {
|
||||
parent.remove(nodes[0]);
|
||||
|
||||
test(stage.ids.myCircle === undefined, 'circle still in hash');
|
||||
test(stage.names.myRect[0] === undefined, 'rect still in hash');
|
||||
test(stage.names.myRect === undefined, 'rect still in hash');
|
||||
|
||||
},
|
||||
'STAGE - set shape and layer alpha to 0.5': function(containerId) {
|
||||
|
Reference in New Issue
Block a user