mirror of
https://github.com/konvajs/konva.git
synced 2025-12-05 03:24:23 +08:00
added hash cleanup logic when nodes are moved from a container. Also added unit tests
This commit is contained in:
@@ -33,6 +33,18 @@ Kinetic.Container.prototype = {
|
||||
*/
|
||||
_remove: function(child) {
|
||||
if(this.children[child.index]._id == child._id) {
|
||||
var stage = this.getStage();
|
||||
stage._removeId(child);
|
||||
stage._removeName(child);
|
||||
|
||||
var go = Kinetic.GlobalObject;
|
||||
for(var n = 0; n < go.tempNodes.length; n++) {
|
||||
var node = go.tempNodes[n];
|
||||
if(node._id === child._id) {
|
||||
go.tempNodes.splice(n, 1);
|
||||
n = go.tempNodes.length;
|
||||
}
|
||||
}
|
||||
|
||||
this.children.splice(child.index, 1);
|
||||
this._setChildrenIndices();
|
||||
@@ -66,13 +78,20 @@ Kinetic.Container.prototype = {
|
||||
this.children.push(child);
|
||||
|
||||
var stage = child.getStage();
|
||||
if (stage === undefined) {
|
||||
var go = Kinetic.GlobalObject;
|
||||
go.tempNodes.push(child);
|
||||
if(stage === undefined) {
|
||||
var go = Kinetic.GlobalObject;
|
||||
go.tempNodes.push(child);
|
||||
}
|
||||
else {
|
||||
stage._addId(child);
|
||||
stage._addName(child);
|
||||
|
||||
/*
|
||||
* pull in other nodes that are now linked
|
||||
* to a stage
|
||||
*/
|
||||
var go = Kinetic.GlobalObject;
|
||||
go._pullNodes(stage);
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user