From 7292abb0286b1a68f3dc6357752d03bd9b1b0eaa Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 27 Jun 2019 01:28:27 +0200 Subject: [PATCH 1/4] IMPROVEMENT: Phase 0 --- FloatingSpace/StrategyPart.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 0849f13c3..7a48b2dfb 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -738,7 +738,16 @@ function newStrategyPart () { for (let i = 0; i < parent.phases.length; i++) { let phase = parent.phases[i] if (phase.id === thisObject.payload.node.id) { - label = label + ' #' + (i + 1) + let parentParent = parent.payload.parentNode + if (parentParent !== undefined) { + if (parentParent.type === 'Initial Definition') { + label = label + ' #' + (i) + } else { + label = label + ' #' + (i + 1) + } + } else { + label = label + ' #' + (i + 1) + } return label } } From 2d7f11c47d9ca3099d946189c64c06b238c7245c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 27 Jun 2019 10:23:46 +0200 Subject: [PATCH 2/4] BUG FIXED: Formula not a number crashes animation --- FloatingSpace/StrategyPart.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 7a48b2dfb..afb01447a 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -433,7 +433,7 @@ function newStrategyPart () { } function setValue (value) { - if (value !== undefined) { + if (value !== undefined && isNaN(value) === false) { formulaValue = value hasValue = true valueCounter = 5 @@ -951,4 +951,3 @@ function newStrategyPart () { } } } - From 69b1b6c916f4240a27047cfb0739fb5fdb78d35c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 27 Jun 2019 11:04:09 +0200 Subject: [PATCH 3/4] BUG FIXED: True returned in formula crashed animation --- FloatingSpace/StrategyPart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index afb01447a..e3c56f8f2 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -433,7 +433,7 @@ function newStrategyPart () { } function setValue (value) { - if (value !== undefined && isNaN(value) === false) { + if (value !== undefined && isNaN(value) === false && (typeof value !== 'boolean')) { formulaValue = value hasValue = true valueCounter = 5 From 4e355dd60f8fd411c6b3b01ca1756d15516ad9c9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 27 Jun 2019 18:21:35 +0200 Subject: [PATCH 4/4] Detaching only with 2 mouse button allowed --- Canvas.js | 4 +++- FloatingSpace/StrategyPart.js | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Canvas.js b/Canvas.js index c99219890..6f5a49c25 100644 --- a/Canvas.js +++ b/Canvas.js @@ -236,7 +236,8 @@ function newCanvas () { try { let point = { x: event.pageX, - y: event.pageY - CURRENT_TOP_MARGIN + y: event.pageY - CURRENT_TOP_MARGIN, + button: event.button } dragVector.downX = point.x @@ -706,3 +707,4 @@ function newCanvas () { } } } + diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index e3c56f8f2..6da021f37 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -79,6 +79,7 @@ function newStrategyPart () { let errorMessage = '' let formulaValue = 0 + let detachingEnabled = false return thisObject @@ -373,6 +374,7 @@ function newStrategyPart () { function detachingPhysics () { if (isDragging !== true) { return } if (thisObject.isFrozen === true) { return } + if (detachingEnabled === 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 @@ -433,7 +435,7 @@ function newStrategyPart () { } function setValue (value) { - if (value !== undefined && isNaN(value) === false && (typeof value !== 'boolean')) { + if (value !== undefined) { formulaValue = value hasValue = true valueCounter = 5 @@ -495,6 +497,11 @@ function newStrategyPart () { thisObject.codeEditor.deactivate() } isDragging = true + if (event.button === 2) { + detachingEnabled = true + } else { + detachingEnabled = false + } } function onDragFinished (event) { @@ -738,16 +745,7 @@ function newStrategyPart () { for (let i = 0; i < parent.phases.length; i++) { let phase = parent.phases[i] if (phase.id === thisObject.payload.node.id) { - let parentParent = parent.payload.parentNode - if (parentParent !== undefined) { - if (parentParent.type === 'Initial Definition') { - label = label + ' #' + (i) - } else { - label = label + ' #' + (i + 1) - } - } else { - label = label + ' #' + (i + 1) - } + label = label + ' #' + (i + 1) return label } } @@ -951,3 +949,4 @@ function newStrategyPart () { } } } +