From b570f87e0ddc4827678312d8ec5bae9e57124d99 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Jan 2020 00:05:15 +0100 Subject: [PATCH] zoom, kind of tunned --- ChartsSpace/ChartUtilities.js | 36 ++++++++++++++--------------- ChartsSpace/ViewPort.js | 43 ++++++++--------------------------- Globals.js | 2 +- Scales/TimeFrameScale.js | 2 +- 4 files changed, 30 insertions(+), 53 deletions(-) diff --git a/ChartsSpace/ChartUtilities.js b/ChartsSpace/ChartUtilities.js index e3ddf4cd7..369974660 100644 --- a/ChartsSpace/ChartUtilities.js +++ b/ChartsSpace/ChartUtilities.js @@ -64,75 +64,75 @@ function getTransparenceFactor (timeFrame) { function recalculatePeriod (zoomLevel) { // console.log(" recalculatePeriod > " + zoomLevel); - if (zoomLevel > 90) { + if (zoomLevel > 400) { return _1_MINUTE_IN_MILISECONDS } - if (zoomLevel > 85) { + if (zoomLevel > 360) { return _2_MINUTES_IN_MILISECONDS } - if (zoomLevel > 80) { + if (zoomLevel > 330) { return _3_MINUTES_IN_MILISECONDS } - if (zoomLevel > 75) { + if (zoomLevel > 300) { return _4_MINUTES_IN_MILISECONDS } - if (zoomLevel > 70) { + if (zoomLevel > 270) { return _5_MINUTES_IN_MILISECONDS } - if (zoomLevel > 65) { + if (zoomLevel > 250) { return _10_MINUTES_IN_MILISECONDS } - if (zoomLevel > 60) { + if (zoomLevel > 230) { return _15_MINUTES_IN_MILISECONDS } - if (zoomLevel > 55) { + if (zoomLevel > 210) { return _20_MINUTES_IN_MILISECONDS } - if (zoomLevel > 50) { + if (zoomLevel > 190) { return _30_MINUTES_IN_MILISECONDS } - if (zoomLevel > 45) { + if (zoomLevel > 170) { return _40_MINUTES_IN_MILISECONDS } - if (zoomLevel > 50) { + if (zoomLevel > 150) { return _45_MINUTES_IN_MILISECONDS } - if (zoomLevel > 35) { + if (zoomLevel > 130) { return _1_HOUR_IN_MILISECONDS } - if (zoomLevel > 30) { + if (zoomLevel > 110) { return _2_HOURS_IN_MILISECONDS } - if (zoomLevel > 25) { + if (zoomLevel > 90) { return _3_HOURS_IN_MILISECONDS } - if (zoomLevel > 20) { + if (zoomLevel > 70) { return _4_HOURS_IN_MILISECONDS } - if (zoomLevel > 15) { + if (zoomLevel > 50) { return _6_HOURS_IN_MILISECONDS } - if (zoomLevel > 10) { + if (zoomLevel > 30) { return _8_HOURS_IN_MILISECONDS } - if (zoomLevel > 5) { + if (zoomLevel > 15) { return _12_HOURS_IN_MILISECONDS } diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index 55250512e..13380cc79 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -3,7 +3,7 @@ function newViewport () { const MODULE_NAME = 'Viewport' const MIN_ZOOM_LEVEL = 0 - const MAX_ZOOM_LEVEL = 100 + const MAX_ZOOM_LEVEL = 500 let ANIMATION_INCREMENT = 0.25 let ANIMATION_STEPS = 5 @@ -134,7 +134,6 @@ function newViewport () { } function physics () { - console.log(position, thisObject.zoomLevel) animationPhysics() positioningphysics() // readObjectState() @@ -181,39 +180,17 @@ function newViewport () { let isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0 if (isMac) { amount = amount / 5 } -/* - if (amount > 0) { - if (thisObject.zoomTargetLevel > -5) { - amount = amount * 2 - } - if (thisObject.zoomTargetLevel > 10) { - amount = amount * 3 - } - if (thisObject.zoomTargetLevel > 15) { - amount = amount * 4 - } + if (thisObject.zoomTargetLevel > 10) { + amount = amount * 2 + } + if (thisObject.zoomTargetLevel > 25) { + amount = amount * 3 + } + if (thisObject.zoomTargetLevel > 50) { + amount = amount * 3.5 } - if (amount < 0) { - if (thisObject.zoomTargetLevel > -4) { - amount = amount * 2 - } - if (thisObject.zoomTargetLevel > 13) { - amount = amount * 3 - } - if (thisObject.zoomTargetLevel > 19) { - amount = amount * 4 - } - } - - if (thisObject.zoomTargetLevel <= -27 && amount < 0) { - amount = amount / 4 - } - if (thisObject.zoomTargetLevel < -27 && amount > 0) { - amount = amount / 4 - } - -*/ + console.log(thisObject.zoomLevel, amount) if (thisObject.zoomTargetLevel + amount > MAX_ZOOM_LEVEL) { return false } diff --git a/Globals.js b/Globals.js index e8fed4264..06fdd3706 100644 --- a/Globals.js +++ b/Globals.js @@ -189,7 +189,7 @@ We define here the size of the chartSpace. It has to bee enough big in order to */ const TIME_MACHINE_WIDTH = 1000; -const TIME_MACHINE_HEIGHT = 200; +const TIME_MACHINE_HEIGHT = 50; function toRadians(angle) { return angle * (Math.PI / 180); diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index ae8523fb5..1e3dd51cc 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -180,7 +180,7 @@ function newTimeFrameScale () { function onViewportZoomChanged (event) { if (event !== undefined) { // it is undefined when the level is just being animated. let currentTimeFrame = thisObject.timeFrame - let timeFrame = currentTimeFrame // recalculatePeriod(event.newLevel) + let timeFrame = recalculatePeriod(event.newLevel) if (timeFrame !== currentTimeFrame) { for (let i = 0; i < timeFramesMasterArray.length; i++) { let timeFrameArray = timeFramesMasterArray[i]