From 711829f46de244cd69f0f3cbbb73fd23680c2445 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 May 2019 17:40:24 +0200 Subject: [PATCH] moveTo refactored --- Canvas.js | 2 +- Container.js | 6 +++--- FloatingSpace/StrategyPartTitle.js | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Canvas.js b/Canvas.js index 52410f6b9..481516273 100644 --- a/Canvas.js +++ b/Canvas.js @@ -744,7 +744,7 @@ function newCanvas () { } if (containerBeingDragged !== undefined) { - let moveSucceed = containerBeingDragged.moveTo(displaceVector) + let moveSucceed = containerBeingDragged.displace(displaceVector) if (moveSucceed === false) { deactivateDragging(event) } diff --git a/Container.js b/Container.js index c29b5ee0b..3fe909ec9 100644 --- a/Container.js +++ b/Container.js @@ -16,7 +16,7 @@ function newContainer () { name: undefined, fitFunction: undefined, isVisibleFunction: undefined, - moveTo: moveTo, + displace: displace, initialize: initialize, finalize: finalize, connectToParent: connectToParent, @@ -188,8 +188,8 @@ function newContainer () { return false } - function moveTo (point) { - /* This function will move the container to the destination point. If it has a visible function will use it + function displace (point) { + /* This function will move the container according to the vector received. If it has a visible function will use it to see if the container can be moved there or not. It wont if the center will not be visible. Returns true if move was possible, false if not. */ diff --git a/FloatingSpace/StrategyPartTitle.js b/FloatingSpace/StrategyPartTitle.js index a13229cd6..8725bd7ce 100644 --- a/FloatingSpace/StrategyPartTitle.js +++ b/FloatingSpace/StrategyPartTitle.js @@ -90,6 +90,14 @@ function newStrategyPartTitle () { function getContainer (point) { let container + if (thisObject.editMode === true) { + if (point.x === VERY_LARGE_NUMBER) { + /* The the mouse leaves the canvas, and event of mouse over with a ridiculous coordinate is triggered so that + anyone can react. In our case, this object has an html input element that is not part of the canvas, so the event is + triggered. We compensate recognizing this coordinate and returning our container. */ + return thisObject.container + } + } if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } else { @@ -233,4 +241,3 @@ function newStrategyPartTitle () { return title } } -