From ebe1b74165226ebb5d076d675b4c3a46db06bf5f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 May 2019 09:53:07 +0200 Subject: [PATCH] Resizing Viewport is now possible --- Globals.js | 8 ++++---- Spaces/BottomSpace.js | 3 ++- ViewPort.js | 30 +++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Globals.js b/Globals.js index 09dfce412..b48c52910 100644 --- a/Globals.js +++ b/Globals.js @@ -159,10 +159,10 @@ maxDate.setDate(maxDate.getDate() + 365 * 1); // We might have charts that proj const MIN_PLOTABLE_DATE = new Date(2015, 0, 1, 0, 0, 0); const MAX_PLOTABLE_DATE = maxDate; -const TOP_SPACE_HEIGHT = 5; -const BOTTOM_SPACE_HEIGHT = 35; -const BREAKPOINT_HEIGHT = 15; -const SIDE_PANEL_WIDTH = 450 +let TOP_SPACE_HEIGHT = 5; +let BOTTOM_SPACE_HEIGHT = 35; +let BREAKPOINT_HEIGHT = 15; +let SIDE_PANEL_WIDTH = 450 const PRODUCT_CARD_STATUS = { ON: 'on', diff --git a/Spaces/BottomSpace.js b/Spaces/BottomSpace.js index 3defae6e1..f9c07db5c 100644 --- a/Spaces/BottomSpace.js +++ b/Spaces/BottomSpace.js @@ -55,7 +55,8 @@ } function physics () { - + BOTTOM_SPACE_HEIGHT = browserCanvas.height - thisObject.container.frame.position.y + viewPort.resize() } function createNewControl (pType, pDrawFunction, pOwner) { diff --git a/ViewPort.js b/ViewPort.js index 11b286d3c..dbfdbde98 100644 --- a/ViewPort.js +++ b/ViewPort.js @@ -10,11 +10,12 @@ function newViewPort () { const CONSOLE_LOG = true let ANIMATION_INCREMENT = 0.25 - const TOP_MARGIN = 15 + TOP_SPACE_HEIGHT - const BOTTOM_MARGIN = 15 + BOTTOM_SPACE_HEIGHT - const LEFT_MARGIN = 50 - const RIGHT_MARGIN = 50 - const MARGINS = { + + let TOP_MARGIN = 15 + TOP_SPACE_HEIGHT + let BOTTOM_MARGIN = 15 + BOTTOM_SPACE_HEIGHT + let LEFT_MARGIN = 50 + let RIGHT_MARGIN = 50 + let MARGINS = { TOP: TOP_MARGIN, BOTTOM: BOTTOM_MARGIN, LEFT: LEFT_MARGIN, @@ -44,6 +45,7 @@ function newViewPort () { animate: animate, draw: draw, raiseEvents: raiseEvents, + resize: resize, initialize: initialize } @@ -76,6 +78,22 @@ function newViewPort () { return thisObject function initialize () { + resize() + readObjectState() + } + + function resize () { + TOP_MARGIN = 15 + TOP_SPACE_HEIGHT + BOTTOM_MARGIN = 15 + BOTTOM_SPACE_HEIGHT + LEFT_MARGIN = 50 + RIGHT_MARGIN = 50 + MARGINS = { + TOP: TOP_MARGIN, + BOTTOM: BOTTOM_MARGIN, + LEFT: LEFT_MARGIN, + RIGHT: RIGHT_MARGIN + } + thisObject.visibleArea = { topLeft: { x: LEFT_MARGIN, y: TOP_MARGIN }, topRight: { x: browserCanvas.width - RIGHT_MARGIN, y: TOP_MARGIN }, @@ -85,8 +103,6 @@ function newViewPort () { thisObject.width = thisObject.visibleArea.topRight.x - thisObject.visibleArea.topLeft.x thisObject.height = thisObject.visibleArea.bottomRight.y - thisObject.visibleArea.topLeft.y - - readObjectState() } function getDisplacement () {