From 401077f99ccfa34bb5c091d78c13aa0c2c6dece7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 8 Jan 2020 19:48:55 +0100 Subject: [PATCH] Scales moving smoothly while with mouse over --- ChartsSpace/TimeMachine.js | 27 ++++++++++++++++++---- ChartsSpace/TimelineChart.js | 43 ++++++++++++++++++++++-------------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index bc96d5c07..c1ab3487f 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -46,6 +46,8 @@ function newTimeMachine () { let onMouseNotOverEventSuscriptionId let timeScaleEventSuscriptionId let rateScaleEventSuscriptionId + let timeScaleMouseOverEventSuscriptionId + let rateScaleMouseOverEventSuscriptionId setupContainer() return thisObject @@ -66,6 +68,8 @@ function newTimeMachine () { thisObject.rateScale.container.eventHandler.stopListening(rateScaleEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) + thisObject.timeScale.container.eventHandler.stopListening(timeScaleMouseOverEventSuscriptionId) + thisObject.rateScale.container.eventHandler.stopListening(rateScaleMouseOverEventSuscriptionId) for (let i = 0; i < thisObject.timelineCharts.length; i++) { let chart = thisObject.timelineCharts[i] @@ -138,14 +142,29 @@ function newTimeMachine () { thisObject.rateScale.visible = false } + timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver) + + function timeScaleMouseOver (event) { + thisObject.rateScale.visible = false + mouse.position.x = event.x + mouse.position.y = event.y + } + + rateScaleMouseOverEventSuscriptionId = thisObject.rateScale.container.eventHandler.listenToEvent('onMouseOver', rateScaleMouseOver) + + function rateScaleMouseOver (event) { + thisObject.timeScale.visible = false + mouse.position.x = event.x + mouse.position.y = event.y + } callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) } function getContainer (point, purpose) { let container - if (thisObject.timeScale !== undefined) { - container = thisObject.timeScale.getContainer(point) + if (thisObject.rateScale !== undefined) { + container = thisObject.rateScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container @@ -153,8 +172,8 @@ function newTimeMachine () { } } - if (thisObject.rateScale !== undefined) { - container = thisObject.rateScale.getContainer(point) + if (thisObject.timeScale !== undefined) { + container = thisObject.timeScale.getContainer(point) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 21cb8b82e..5bbdeb563 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -51,6 +51,7 @@ function newTimelineChart () { let onMouseOverEventSuscriptionId let onMouseNotOverEventSuscriptionId let timeFrameScaleEventSuscriptionId + let timeFrameScaleMouseOverEventSuscriptionId let mouse = { position: { @@ -74,6 +75,7 @@ function newTimelineChart () { thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSuscriptionId) thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleEventSuscriptionId) + thisObject.timeFrameScale.container.eventHandler.stopListening(timeFrameScaleMouseOverEventSuscriptionId) plotterManager.finalize() plotterManager = undefined @@ -94,23 +96,6 @@ function newTimelineChart () { market = pMarket timeLineCoordinateSystem = pTimeLineCoordinateSystem - onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - - function onMouseOver (event) { - thisObject.timeFrameScale.visible = true - - mouse.position.x = event.x - mouse.position.y = event.y - - saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) - } - - onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - - function onMouseNotOver (event) { - thisObject.timeFrameScale.visible = false - } - let panelOwner = exchange + ' ' + market.quotedAsset + '/' + market.baseAsset productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel', undefined, panelOwner) let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle, panelOwner) @@ -192,6 +177,30 @@ function newTimelineChart () { thisObject.timeFrameScale.initialize() + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + + function onMouseOver (event) { + thisObject.timeFrameScale.visible = true + + mouse.position.x = event.x + mouse.position.y = event.y + + saveUserPosition(thisObject.container, timeLineCoordinateSystem, event) + } + + onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + function onMouseNotOver (event) { + thisObject.timeFrameScale.visible = false + } + + timeFrameScaleMouseOverEventSuscriptionId = thisObject.timeFrameScale.container.eventHandler.listenToEvent('onMouseOver', timeFrameScaleMouseOver) + + function timeFrameScaleMouseOver (event) { + mouse.position.x = event.x + mouse.position.y = event.y + } + initializationReady = true callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) return