diff --git a/Canvas.js b/Canvas.js index 18fe9869e..c8821179e 100644 --- a/Canvas.js +++ b/Canvas.js @@ -783,7 +783,7 @@ function newCanvas () { /* We check if the mouse is over a panel/ */ if (thisObject.panelsSpace !== undefined) { - container = thisObject.panelsSpace.getContainer(point) + container = thisObject.panelsSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) if (container !== undefined && container.detectMouseOver === true) { containerFound() diff --git a/Panels/LayersPanel.js b/Panels/LayersPanel.js index 9381a844b..b95821ad7 100644 --- a/Panels/LayersPanel.js +++ b/Panels/LayersPanel.js @@ -18,8 +18,11 @@ function newLayersPanel () { thisObject.container.initialize() thisObject.container.isDraggeable = true thisObject.container.isWheelable = true + thisObject.container.detectMouseOver = true let isInitialized = false + let isMouseOver = false + let mouseOverCounter = 0 let layersMap = new Map() let visibleLayers = [] @@ -36,10 +39,12 @@ 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 @@ -74,6 +79,7 @@ function newLayersPanel () { thisObject.panelTabButton.initialize() onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) readObjectState() @@ -166,6 +172,11 @@ function newLayersPanel () { } } + function onMouseOver (event) { + isMouseOver = true + mouseOverCounter = 100 + } + function onMouseWheel (event) { delta = event.wheelDelta if (delta > 0) { @@ -239,7 +250,7 @@ function newLayersPanel () { thisObject.container.eventHandler.raiseEvent('Layer Status Changed', layer) } - function getContainer (point) { + function getContainer (point, purpose) { if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return } let container @@ -261,7 +272,9 @@ function newLayersPanel () { checkPoint = thisObject.fitFunction(checkPoint) if (point.x === checkPoint.x && point.y === checkPoint.y) { - return container + if (container.isForThisPurpose(purpose)) { + return container + } } } } @@ -291,8 +304,18 @@ function newLayersPanel () { readObjectState() } + function mouseOverPhysics () { + mouseOverCounter-- + if (mouseOverCounter < 0) { + mouseOverCounter = 0 + isMouseOver = false + } + } + function physics () { if (isInitialized === false) { return } + + mouseOverPhysics() thisObject.panelTabButton.physics() saveFrame(thisObject.payload, thisObject.container.frame) syncWithConfigPhysics() @@ -369,7 +392,7 @@ function newLayersPanel () { } function draw () { - if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return } + if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true || isMouseOver === false) { return } // thisObject.container.frame.draw(false, false, false, thisObject.fitFunction) diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index b1bd3ebc6..970226f67 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -326,7 +326,7 @@ function newPanelsSpace () { } } - function getContainer (point) { + function getContainer (point, purpose) { if (thisObject.visible !== true) { return } let container @@ -339,7 +339,7 @@ function newPanelsSpace () { let owner = canvas.chartingSpace.inViewport.get(panel.owner) if (owner !== undefined) { if (panel.isVisible === true && panel.isHidden === false) { - container = panel.getContainer(point) + container = panel.getContainer(point, purpose) } } if (container !== undefined) {