From 8090745478b9d80c09057de8401f1eaa2600c0a0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 7 Mar 2020 19:08:01 +0100 Subject: [PATCH] double click working --- ChartingSpace/EdgeEditor.js | 8 ++------ ChartingSpace/Viewport.js | 13 +++++++++---- Globals.js | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ChartingSpace/EdgeEditor.js b/ChartingSpace/EdgeEditor.js index 3b8527410..fa46141a4 100644 --- a/ChartingSpace/EdgeEditor.js +++ b/ChartingSpace/EdgeEditor.js @@ -106,12 +106,8 @@ function newEdgeEditor () { function onDoubleClick () { doubleClickCounter = 0 - - canvas.chartingSpace.viewport.displaceToContainer(thisObject.container.parentContainer) - - if (canvas.chartingSpace.viewport.zoomLevel === DOUBLE_CLICK_ZOOM_IN_LEVEL) { - canvas.chartingSpace.viewport.zoomAtCenter(DOUBLE_CLICK_ZOOM_OUT_LEVEL) - } else { + if (canvas.chartingSpace.viewport.zoomLevel === DOUBLE_CLICK_ZOOM_OUT_LEVEL) { + canvas.chartingSpace.viewport.displaceToContainer(thisObject.container.parentContainer) canvas.chartingSpace.viewport.zoomAtCenter(DOUBLE_CLICK_ZOOM_IN_LEVEL) } } diff --git a/ChartingSpace/Viewport.js b/ChartingSpace/Viewport.js index 12a27c44b..bd650b24d 100644 --- a/ChartingSpace/Viewport.js +++ b/ChartingSpace/Viewport.js @@ -146,6 +146,7 @@ function newViewport () { function zoomAtCenter (level) { thisObject.zoomTargetLevel = level overrideMousePositionCounter = 50 + ANIMATION_INCREMENT = 0.5 } function mousePositionPhysics () { @@ -153,7 +154,7 @@ function newViewport () { thisObject.mousePosition.x = browserCanvas.width / 2 thisObject.mousePosition.y = (browserCanvas.height - TOP_SPACE_HEIGHT) / 2 - TOP_SPACE_HEIGHT / 2 - console.log('SETTING MOUSE TO CENTER', overrideMousePositionCounter, thisObject.zoomLevel, thisObject.zoomTargetLevel) + console.log('SETTING MOUSE TO CENTER ', 'COUNTER ' + overrideMousePositionCounter, 'zoomLevel ' + thisObject.zoomLevel, 'zoomTargetLevel ' + thisObject.zoomTargetLevel) overrideMousePositionCounter-- if (overrideMousePositionCounter < 0) { overrideMousePositionCounter = 0 @@ -185,6 +186,8 @@ function newViewport () { } thisObject.zoomLevel = Math.round((thisObject.zoomLevel + ANIMATION_INCREMENT) * 100) / 100 changeZoom(thisObject.zoomLevel - ANIMATION_INCREMENT, thisObject.zoomLevel) + + console.log('ANIMATION_INCREMENT ' + ANIMATION_INCREMENT) } if (thisObject.zoomLevel > thisObject.zoomTargetLevel) { @@ -193,6 +196,8 @@ function newViewport () { } thisObject.zoomLevel = Math.round((thisObject.zoomLevel - ANIMATION_INCREMENT) * 100) / 100 changeZoom(thisObject.zoomLevel + ANIMATION_INCREMENT, thisObject.zoomLevel) + + console.log('ANIMATION_INCREMENT ' + ANIMATION_INCREMENT) } } @@ -222,9 +227,9 @@ function newViewport () { if (thisObject.zoomTargetLevel + amount * morePower < MIN_ZOOM_LEVEL) { return false } - thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount * morePower + thisObject.zoomTargetLevel = Math.round(thisObject.zoomTargetLevel + amount * morePower) - ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS + ANIMATION_INCREMENT = Math.round(Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS * 100) / 100 let newEvent = { newLevel: thisObject.zoomTargetLevel, @@ -305,7 +310,7 @@ function newViewport () { saveObjectState() - console.log('ZOOM LEVEL CHANGED', oldLevel, newLevel) + console.log('ZOOM LEVEL CHANGED', 'oldLevel = ' + oldLevel, 'newLevel = ' + newLevel) thisObject.eventHandler.raiseEvent('Zoom Changed') } diff --git a/Globals.js b/Globals.js index 949cb3941..f9f463746 100644 --- a/Globals.js +++ b/Globals.js @@ -169,7 +169,7 @@ const _2_MINUTES_IN_MILISECONDS = 2 * 60 * 1000; const _1_MINUTE_IN_MILISECONDS = 1 * 60 * 1000; const DOUBLE_CLICK_ZOOM_OUT_LEVEL = 0 -const DOUBLE_CLICK_ZOOM_IN_LEVEL = 7 +const DOUBLE_CLICK_ZOOM_IN_LEVEL = 8 let NEW_SESSION_INITIAL_DATE = new Date(); // This value will be overwritten at the canvas.chartingSpace.viewport.initialize if the user had a prevous session with this same browser. let INITIAL_ZOOM_LEVEL = -28.25 // This is the zoom level at the view port in which the APP starts.