From ba66db2907fc3058c08ce6842e9e06d91fe02f27 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 7 Mar 2020 18:41:49 +0100 Subject: [PATCH] almost there --- ChartingSpace/EdgeEditor.js | 2 +- ChartingSpace/Viewport.js | 23 +++++++++++++++++------ Globals.js | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ChartingSpace/EdgeEditor.js b/ChartingSpace/EdgeEditor.js index c321cb84d..3b8527410 100644 --- a/ChartingSpace/EdgeEditor.js +++ b/ChartingSpace/EdgeEditor.js @@ -107,7 +107,7 @@ function newEdgeEditor () { function onDoubleClick () { doubleClickCounter = 0 - // canvas.chartingSpace.viewport.displaceToContainer(thisObject.container.parentContainer) + 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) diff --git a/ChartingSpace/Viewport.js b/ChartingSpace/Viewport.js index c4de37f78..12a27c44b 100644 --- a/ChartingSpace/Viewport.js +++ b/ChartingSpace/Viewport.js @@ -40,6 +40,7 @@ function newViewport () { fitIntoVisibleArea: fitIntoVisibleArea, fitIntoViewport: fitIntoViewport, displace: displace, + displaceToContainer: displaceToContainer, physics: physics, raiseEvents: raiseEvents, resize: resize, @@ -133,10 +134,24 @@ function newViewport () { thisObject.eventHandler.raiseEvent('Position Changed', event) } + function displaceToContainer (container) { + let targetPoint = { + x: -container.frame.position.x - container.frame.width / 2, + y: -container.frame.position.y - container.frame.height / 2 + TOP_SPACE_HEIGHT + } + position.x = targetPoint.x + thisObject.width / 2 + position.y = targetPoint.y + thisObject.height / 2 + } + + function zoomAtCenter (level) { + thisObject.zoomTargetLevel = level + overrideMousePositionCounter = 50 + } + function mousePositionPhysics () { if (overrideMousePositionCounter > 0) { thisObject.mousePosition.x = browserCanvas.width / 2 - thisObject.mousePosition.y = (browserCanvas.height - TOP_SPACE_HEIGHT) / 2 + TOP_SPACE_HEIGHT + thisObject.mousePosition.y = (browserCanvas.height - TOP_SPACE_HEIGHT) / 2 - TOP_SPACE_HEIGHT / 2 console.log('SETTING MOUSE TO CENTER', overrideMousePositionCounter, thisObject.zoomLevel, thisObject.zoomTargetLevel) overrideMousePositionCounter-- @@ -280,11 +295,6 @@ function newViewport () { thisObject.eventHandler.raiseEvent('Position Changed', event) } - function zoomAtCenter (level) { - thisObject.zoomTargetLevel = level - overrideMousePositionCounter = 10 - } - function changeZoom (oldLevel, newLevel) { if (thisObject.visible === false) { return } let oldMouse = unTransformThisPoint(thisObject.mousePosition, oldLevel) @@ -406,3 +416,4 @@ function newViewport () { } } } + diff --git a/Globals.js b/Globals.js index 075f36207..949cb3941 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 = 2 +const DOUBLE_CLICK_ZOOM_IN_LEVEL = 7 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.