From edefade22a04c5416389ed424a308c459492f699 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 10 Feb 2020 19:52:05 +0100 Subject: [PATCH] Borders with limits --- ChartsSpace/EdgeEditor.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ChartsSpace/EdgeEditor.js b/ChartsSpace/EdgeEditor.js index c94b495fd..5ddad9ca7 100644 --- a/ChartsSpace/EdgeEditor.js +++ b/ChartsSpace/EdgeEditor.js @@ -91,8 +91,17 @@ function newEdgeEditor () { function physics () { if (thisObject.container.frame.position.x === 0 && thisObject.container.frame.position.y === 0) { return } + + const MIN_WIDTH = 100 + const MIN_HEIGHT = 50 + switch (whereIsMouseOver) { case 'top' : { + if (thisObject.container.parentContainer.frame.height - thisObject.container.frame.position.y < MIN_HEIGHT) { + thisObject.container.frame.position.x = 0 + thisObject.container.frame.position.y = 0 + return + } thisObject.container.parentContainer.frame.position.y = thisObject.container.parentContainer.frame.position.y + thisObject.container.frame.position.y thisObject.container.parentContainer.frame.height = thisObject.container.parentContainer.frame.height - thisObject.container.frame.position.y thisObject.container.frame.position.x = 0 @@ -101,6 +110,11 @@ function newEdgeEditor () { break } case 'bottom' : { + if (thisObject.container.parentContainer.frame.height + thisObject.container.frame.position.y < MIN_HEIGHT) { + thisObject.container.frame.position.x = 0 + thisObject.container.frame.position.y = 0 + return + } thisObject.container.parentContainer.frame.height = thisObject.container.parentContainer.frame.height + thisObject.container.frame.position.y thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 @@ -108,6 +122,11 @@ function newEdgeEditor () { break } case 'left' : { + if (thisObject.container.parentContainer.frame.width - thisObject.container.frame.position.x < MIN_WIDTH) { + thisObject.container.frame.position.x = 0 + thisObject.container.frame.position.y = 0 + return + } thisObject.container.parentContainer.frame.position.x = thisObject.container.parentContainer.frame.position.x + thisObject.container.frame.position.x thisObject.container.parentContainer.frame.width = thisObject.container.parentContainer.frame.width - thisObject.container.frame.position.x thisObject.container.frame.position.x = 0 @@ -116,6 +135,11 @@ function newEdgeEditor () { break } case 'right' : { + if (thisObject.container.parentContainer.frame.width + thisObject.container.frame.position.x < MIN_WIDTH) { + thisObject.container.frame.position.x = 0 + thisObject.container.frame.position.y = 0 + return + } thisObject.container.parentContainer.frame.width = thisObject.container.parentContainer.frame.width + thisObject.container.frame.position.x thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0