From af707fd918c22ce3d1744488415801f8681138bc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 30 Jun 2019 13:56:29 +0200 Subject: [PATCH] Right Dragging for attaching & detaching functionality --- FloatingSpace/StrategyPart.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index f05522867..565554632 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -79,7 +79,7 @@ function newStrategyPart () { let errorMessage = '' let formulaValue = 0 - let detachingEnabled = false + let rightDragging = false return thisObject @@ -189,6 +189,7 @@ function newStrategyPart () { if (thisObject.isOnFocus !== true) { return } if (isDragging !== true) { return } + if (rightDragging !== true) { return } if (thisObject.payload.chainParent !== undefined) { return } let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects @@ -374,7 +375,7 @@ function newStrategyPart () { function detachingPhysics () { if (isDragging !== true) { return } if (thisObject.isFrozen === true) { return } - if (detachingEnabled === false) { return } + if (rightDragging === false) { return } let distanceToChainParent = Math.sqrt(Math.pow(thisObject.payload.position.x - thisObject.payload.targetPosition.x, 2) + Math.pow(thisObject.payload.position.y - thisObject.payload.targetPosition.y, 2)) let ratio = distanceToChainParent / previousDistance @@ -498,9 +499,9 @@ function newStrategyPart () { } isDragging = true if (event.button === 2) { - detachingEnabled = true + rightDragging = true } else { - detachingEnabled = false + rightDragging = false } }