From 7ba21f85bfe36b36adfdb414c4065ee0442ac0d9 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 14 Nov 2012 23:46:28 -0300 Subject: [PATCH] Fix 'element could not be removed:[object Object] fixed. --- mindplot/src/main/javascript/DragTopic.js | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mindplot/src/main/javascript/DragTopic.js b/mindplot/src/main/javascript/DragTopic.js index a1750c64..e39c2c97 100644 --- a/mindplot/src/main/javascript/DragTopic.js +++ b/mindplot/src/main/javascript/DragTopic.js @@ -115,14 +115,16 @@ mindplot.DragTopic = new Class({ }, removeFromWorkspace:function (workspace) { - // Remove drag shadow. - workspace.removeChild(this._elem2d); - this._isInWorkspace = false; + if (this._isInWorkspace) { + // Remove drag shadow. + workspace.removeChild(this._elem2d); - // Remove pivot shape. To improve performace it will not be removed. Only the visibility will be changed. - var dragPivot = this._getDragPivot(); - dragPivot.setVisibility(false); + // Remove pivot shape. To improve performance it will not be removed. Only the visibility will be changed. + var dragPivot = this._getDragPivot(); + dragPivot.setVisibility(false); + this._isInWorkspace = false; + } }, isInWorkspace:function () { @@ -130,10 +132,12 @@ mindplot.DragTopic = new Class({ }, addToWorkspace:function (workspace) { - workspace.appendChild(this._elem2d); - var dragPivot = this._getDragPivot(); - dragPivot.addToWorkspace(workspace); - this._isInWorkspace = true; + if (!this._isInWorkspace) { + workspace.appendChild(this._elem2d); + var dragPivot = this._getDragPivot(); + dragPivot.addToWorkspace(workspace); + this._isInWorkspace = true; + } }, _getDragPivot:function () {