From 2c13f6dcb39e110f20126941227ae0838650a090 Mon Sep 17 00:00:00 2001 From: whtv <28059402+whtv@users.noreply.github.com> Date: Sat, 4 Dec 2021 16:23:23 +0100 Subject: [PATCH] Fix dragging nodes out of bounds --- .../Foundations/UI/Spaces/Floating-Space/FloatingSpace.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Projects/Foundations/UI/Spaces/Floating-Space/FloatingSpace.js b/Projects/Foundations/UI/Spaces/Floating-Space/FloatingSpace.js index 7595b89a9..9a3362a95 100644 --- a/Projects/Foundations/UI/Spaces/Floating-Space/FloatingSpace.js +++ b/Projects/Foundations/UI/Spaces/Floating-Space/FloatingSpace.js @@ -347,6 +347,10 @@ function newFoundationsFloatingSpace() { y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 } + /* Do not displace if we would end up out of bounds */ + if (thisObject.container.frame.position.y + displaceVector.y > + -(TOP_SPACE_HEIGHT + COCKPIT_SPACE_HEIGHT) * thisObject.container.frame.height / browserCanvas.height) { return } + thisObject.container.displace(displaceVector) return displaceVector } @@ -357,6 +361,7 @@ function newFoundationsFloatingSpace() { x: 0, y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 } + if (thisObject.container.frame.position.y + displaceVector.y + thisObject.container.frame.height < browserCanvas.height) { return } thisObject.container.displace(displaceVector) return displaceVector @@ -368,6 +373,7 @@ function newFoundationsFloatingSpace() { x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100, y: 0 } + if (thisObject.container.frame.position.x + displaceVector.x > 0) { return } thisObject.container.displace(displaceVector) return displaceVector @@ -379,6 +385,7 @@ function newFoundationsFloatingSpace() { x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100, y: 0 } + if (thisObject.container.frame.position.x + displaceVector.x + thisObject.container.frame.width < browserCanvas.width) { return } thisObject.container.displace(displaceVector) return displaceVector