Commit fbb1b81e authored by campaign's avatar campaign

修复孤立node节点容错

parent c0f3895f
...@@ -40,6 +40,7 @@ kity.extendClass(Minder, { ...@@ -40,6 +40,7 @@ kity.extendClass(Minder, {
handelNodeCreate: function(node) { handelNodeCreate: function(node) {
var rc = this._rc; var rc = this._rc;
node.traverse(function(current) { node.traverse(function(current) {
current.attached = true;
rc.addShape(current.getRenderContainer()); rc.addShape(current.getRenderContainer());
}); });
rc.addShape(node.getRenderContainer()); rc.addShape(node.getRenderContainer());
...@@ -48,6 +49,7 @@ kity.extendClass(Minder, { ...@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
handelNodeRemove: function(node) { handelNodeRemove: function(node) {
var rc = this._rc; var rc = this._rc;
node.traverse(function(current) { node.traverse(function(current) {
current.attached = false;
rc.removeShape(current.getRenderContainer()); rc.removeShape(current.getRenderContainer());
}); });
}, },
......
...@@ -185,6 +185,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', { ...@@ -185,6 +185,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
if (index >= 0) { if (index >= 0) {
removed = this.children.splice(index, 1)[0]; removed = this.children.splice(index, 1)[0];
removed.parent = null; removed.parent = null;
removed.root = removed;
} }
}, },
......
...@@ -27,6 +27,7 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', { ...@@ -27,6 +27,7 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
kity.extendClass(Minder, { kity.extendClass(Minder, {
_createRendererForNode: function(node) { _createRendererForNode: function(node) {
var registered = this._renderers; var registered = this._renderers;
var renderers = []; var renderers = [];
...@@ -48,6 +49,7 @@ kity.extendClass(Minder, { ...@@ -48,6 +49,7 @@ kity.extendClass(Minder, {
}, },
renderNode: function(node) { renderNode: function(node) {
var rendererClasses = this._renderers; var rendererClasses = this._renderers;
var g = KityMinder.Geometry; var g = KityMinder.Geometry;
var i, latestBox, renderer; var i, latestBox, renderer;
...@@ -107,6 +109,7 @@ kity.extendClass(Minder, { ...@@ -107,6 +109,7 @@ kity.extendClass(Minder, {
kity.extendClass(MinderNode, { kity.extendClass(MinderNode, {
render: function() { render: function() {
if (!this.attached) return;
this.getMinder().renderNode(this); this.getMinder().renderNode(this);
return this; return this;
}, },
......
...@@ -123,7 +123,9 @@ KityMinder.registerModule("HistoryModule", function() { ...@@ -123,7 +123,9 @@ KityMinder.registerModule("HistoryModule", function() {
traverseNode(km.getRoot(), target); traverseNode(km.getRoot(), target);
km.layout(); km.layout();
km.select(selectedNodes,true); km.select(selectedNodes,true);
selectedNodes = []; selectedNodes = [];
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment