From b9638b4c99236f55185377e038f99c6d8f30141e Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Sat, 21 Jan 2012 10:57:15 -0300 Subject: [PATCH] Integrate free positioning predict on drag. --- mindplot/src/main/javascript/Designer.js | 3 +-- mindplot/src/main/javascript/DragTopic.js | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index 848549b7..744fe8ea 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -137,8 +137,7 @@ mindplot.Designer = new Class({ if (!dragTopic.isVisible() && dragTopic.isConnected()) { dragTopic.setVisibility(true); } - - } + } }); dragger.addEvent('enddragging', function(event, dragTopic) { diff --git a/mindplot/src/main/javascript/DragTopic.js b/mindplot/src/main/javascript/DragTopic.js index 53e796e2..51e69639 100644 --- a/mindplot/src/main/javascript/DragTopic.js +++ b/mindplot/src/main/javascript/DragTopic.js @@ -34,26 +34,31 @@ mindplot.DragTopic = new Class({ }, setPosition : function(x, y) { - this._position.setValue(x, y); + // Update drag shadow position .... + var position = {x:x,y:y}; + if (this.isFreeLayoutOn() && this.isConnected()) { + var _layoutManager = designer._eventBussDispatcher._layoutManager; + var par = this.getConnectedToTopic(); + position = _layoutManager.predict(par.getId(), position, true).position; + } + this._position.setValue(position.x, position.y); // Elements are positioned in the center. // All topic element must be positioned based on the innerShape. var draggedNode = this._draggedNode; var size = draggedNode.getSize(); - - var cx = Math.ceil(x - (size.width / 2)); - var cy = Math.ceil(y - (size.height / 2)); - - // Update visual position. + var cx = Math.ceil(position.x - (size.width / 2)); + var cy = Math.ceil(position.y - (size.height / 2)); this._elem2d.setPosition(cx, cy); + // In case is not free, pivot must be draw ... if (this.isConnected() && !this.isFreeLayoutOn()) { var parent = this.getConnectedToTopic(); var predict = designer._eventBussDispatcher._layoutManager.predict(parent.getId(), this.getPosition()); if (this._order != predict.order) { var dragPivot = this._getDragPivot(); - var position = predict.position; - dragPivot.connectTo(parent, position); + var pivotPosition = predict.position; + dragPivot.connectTo(parent, pivotPosition); this.setOrder(predict.order); } } @@ -141,7 +146,7 @@ mindplot.DragTopic = new Class({ }, - isInWorkspace: function(){ + isInWorkspace: function() { return this._isInWorkspace; },