From 778cebdb0ac67f8ce84a78894458167b1af830eb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 8 Mar 2020 20:21:26 +0100 Subject: [PATCH] bug mac users --- CanvasApp/ChartingSpace/Viewport.js | 6 ++++-- CanvasApp/Panels/LayersPanel.js | 18 ------------------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/CanvasApp/ChartingSpace/Viewport.js b/CanvasApp/ChartingSpace/Viewport.js index 2f5dad3e7..7ec366e40 100644 --- a/CanvasApp/ChartingSpace/Viewport.js +++ b/CanvasApp/ChartingSpace/Viewport.js @@ -197,6 +197,8 @@ function newViewport () { } function onMouseWheel (event) { + const MAC_AMOUNT_FACTOR = 5 + if (thisObject.visible === false) { return } if ((event.ctrlKey === true || event.metaKey === true)) { return } let morePower = 1 @@ -204,7 +206,7 @@ function newViewport () { if (event.buttons === 4) { morePower = 2 } // Mouse wheel pressed. /* We adjust the sensitivity for Mac Users */ let isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0 - if (isMac) { amount = amount / 5 } + if (isMac) { amount = amount / MAC_AMOUNT_FACTOR } if (thisObject.zoomTargetLevel > 10) { amount = amount * 2 @@ -222,7 +224,7 @@ function newViewport () { if (thisObject.zoomTargetLevel + amount * morePower < MIN_ZOOM_LEVEL) { return false } - thisObject.zoomTargetLevel = Math.round(thisObject.zoomTargetLevel + amount * morePower) + thisObject.zoomTargetLevel = Math.round((thisObject.zoomTargetLevel + amount * morePower) * MAC_AMOUNT_FACTOR) / MAC_AMOUNT_FACTOR ANIMATION_INCREMENT = Math.round(Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / ANIMATION_STEPS * 100) / 100 diff --git a/CanvasApp/Panels/LayersPanel.js b/CanvasApp/Panels/LayersPanel.js index ee8bbcd7c..ba6823d27 100644 --- a/CanvasApp/Panels/LayersPanel.js +++ b/CanvasApp/Panels/LayersPanel.js @@ -21,7 +21,6 @@ function newLayersPanel () { thisObject.container.detectMouseOver = true let isInitialized = false - let isMouseOver = false let mouseOverCounter = 0 let layersMap = new Map() @@ -39,12 +38,10 @@ function newLayersPanel () { let posiblePanelHeight = (layerHeight + LAYER_SEPARATION) * posibleVisibleLayers + headerHeight + footerHeight let onMouseWheelEventSuscriptionId - let onMouseOverEventSuscriptionId return thisObject function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) - thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId) thisObject.panelTabButton.finalize() thisObject.panelTabButton = undefined @@ -79,7 +76,6 @@ function newLayersPanel () { thisObject.panelTabButton.initialize() onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) readObjectState() @@ -172,11 +168,6 @@ function newLayersPanel () { } } - function onMouseOver (event) { - isMouseOver = true - mouseOverCounter = 150 - } - function onMouseWheel (event) { delta = event.wheelDelta if (delta > 0) { @@ -304,19 +295,10 @@ function newLayersPanel () { readObjectState() } - function mouseOverPhysics () { - mouseOverCounter-- - if (mouseOverCounter < 0) { - mouseOverCounter = 0 - isMouseOver = false - } - } - function physics () { if (isInitialized === false) { return } if (thisObject.payload.node === undefined) { return } - mouseOverPhysics() thisObject.panelTabButton.physics() saveFrame(thisObject.payload, thisObject.container.frame) syncWithConfigPhysics()