From a9c1dd6eccf159b4f257a95d680a6bd4db8e7a68 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 10 Apr 2019 15:43:53 +0200 Subject: [PATCH] Changes is Mouse Wheel --- BottomSpace/ChartAspectRatio.js | 12 +++++++----- Canvas.js | 8 +++++--- Panels/ProductsPanel.js | 11 ++++++----- Scales/RightScale.js | 9 +++++---- Scales/TimeScale.js | 5 +++-- Spaces/ChartSpace.js | 2 +- TimeMachine.js | 4 ++-- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/BottomSpace/ChartAspectRatio.js b/BottomSpace/ChartAspectRatio.js index 16b4ffe3d..e32b17292 100644 --- a/BottomSpace/ChartAspectRatio.js +++ b/BottomSpace/ChartAspectRatio.js @@ -53,16 +53,18 @@ container.frame.position.y = viewPort.visibleArea.bottomLeft.y } - function onMouseWheel (pDelta) { + function onMouseWheel (event) { + delta = event.wheelDelta + if (viewPort.isMinZoom() === false) { return } // We only make this button to work at the min zoom level. - if (pDelta < 0) { - pDelta = -0.1 + if (delta < 0) { + delta = -0.1 } else { - pDelta = 0.1 + delta = 0.1 } - thisObject.aspectRatio.y = thisObject.aspectRatio.y + pDelta + thisObject.aspectRatio.y = thisObject.aspectRatio.y + delta thisObject.aspectRatio.y = Math.round(thisObject.aspectRatio.y * 100) / 100 if (thisObject.aspectRatio.y < MIN_Y_ASPECT_RATIO) { diff --git a/Canvas.js b/Canvas.js index 1ce920ec7..aff397357 100644 --- a/Canvas.js +++ b/Canvas.js @@ -572,10 +572,12 @@ function newCanvas () { y: event.pageY - window.canvasApp.topMargin } + event.mousePosition = point + let panelContainer = canvas.panelsSpace.getContainer({ x: point.x, y: point.y }) if (panelContainer !== undefined && panelContainer.isWheelable === true) { - panelContainer.eventHandler.raiseEvent('Mouse Wheel', event.wheelDelta) + panelContainer.eventHandler.raiseEvent('Mouse Wheel', event) return false // This instructs the browser not to take the event and scroll the page. } @@ -593,7 +595,7 @@ function newCanvas () { let bottomContainer = canvas.bottomSpace.getContainer({ x: point.x, y: point.y }) if (bottomContainer !== undefined && bottomContainer.isWheeleable === true) { - bottomContainer.eventHandler.raiseEvent('Mouse Wheel', event.wheelDelta) + bottomContainer.eventHandler.raiseEvent('Mouse Wheel', event) return false // This instructs the browser not to take the event and scroll the page. } @@ -602,7 +604,7 @@ function newCanvas () { let chartContainer = canvas.chartSpace.getContainer({ x: point.x, y: point.y }) if (chartContainer !== undefined && chartContainer.isWheeleable === true) { - chartContainer.eventHandler.raiseEvent('Mouse Wheel', event.wheelDelta) + chartContainer.eventHandler.raiseEvent('Mouse Wheel', event) return false // This instructs the browser not to take the event and scroll the page. } else { /* If all the above fails, we fallback into applying zoom to the viewPort */ diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 40c51bed0..506460406 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -138,14 +138,15 @@ isInitialized = true } - function onMouseWheel (pDelta) { - if (pDelta > 0) { - pDelta = -1 + function onMouseWheel (event) { + delta = event.wheelDelta + if (delta > 0) { + delta = -1 } else { - pDelta = 1 + delta = 1 } - firstVisibleCard = firstVisibleCard + pDelta + firstVisibleCard = firstVisibleCard + delta let availableSlots = visibleProductCards.length diff --git a/Scales/RightScale.js b/Scales/RightScale.js index c37f63994..fc6a7ae3d 100644 --- a/Scales/RightScale.js +++ b/Scales/RightScale.js @@ -28,11 +28,12 @@ thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel) } - function onMouseWheel (pDelta) { - if (pDelta < 0) { - pDelta = -0.1 + function onMouseWheel (event) { + delta = event.wheelDelta + if (delta < 0) { + delta = -0.1 } else { - pDelta = 0.1 + delta = 0.1 } } diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 8d773322d..dad410593 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -29,8 +29,9 @@ function newTimeScale () { thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel) } - function onMouseWheel (pDelta) { - if (pDelta < 0) { + function onMouseWheel (event) { + delta = event.wheelDelta + if (delta < 0) { thisObject.lenghtPercentage = thisObject.lenghtPercentage - 10 if (thisObject.lenghtPercentage < 50) { thisObject.lenghtPercentage = 50 } } else { diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js index 1e7ee8abf..39ef77ea7 100644 --- a/Spaces/ChartSpace.js +++ b/Spaces/ChartSpace.js @@ -27,7 +27,7 @@ function newChartSpace () { thisObject.container.initialize(MODULE_NAME) thisObject.container.frame.width = CHART_SPACE_WIDTH - thisObject.container.frame.height = CHART_SPACE_HEIGHT + thisObject.container.frame.height = CHART_SPACE_HEIGHT * canvas.bottomSpace.chartAspectRatio.aspectRatio.y thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2 thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2 diff --git a/TimeMachine.js b/TimeMachine.js index 90106c4df..8f4719253 100644 --- a/TimeMachine.js +++ b/TimeMachine.js @@ -77,7 +77,7 @@ function newTimeMachine () { timelineChart.container.connectToParent(thisObject.container, true, true) - timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y + timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 timelineChart.container.frame.position.y = timelineChart.container.frame.height * SEPARATION_BETWEEN_TIMELINE_CHARTS * position @@ -137,7 +137,7 @@ function newTimeMachine () { timelineChart.container.connectToParent(thisObject.container, true, true) - timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y + timelineChart.container.frame.height = thisObject.container.frame.height timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2 timelineChart.container.frame.position.y = timelineChart.container.frame.height * SEPARATION_BETWEEN_TIMELINE_CHARTS * position