From 761e7cf8aeb7e01ab5ce0d4919c597c83a1f3dc8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 15 Oct 2018 17:31:09 +0200 Subject: [PATCH] TOP MARGIN implemented --- Canvas.js | 57 ++++++++++++++++++++++++++--------------- Scripts/AppPreLoader.js | 4 ++- index.html | 4 ++- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/Canvas.js b/Canvas.js index 26b87409c..bc235b45d 100644 --- a/Canvas.js +++ b/Canvas.js @@ -287,14 +287,14 @@ function newCanvas() { */ - dragVector.downX = event.pageX; - dragVector.downY = event.pageY; - let point = { x: event.pageX, - y: event.pageY + y: event.pageY - window.TOP_MARGIN }; + dragVector.downX = point.x; + dragVector.downY = point.y; + let container; /* We check if the mouse is over an element of the Top Space / */ @@ -332,7 +332,7 @@ function newCanvas() { /* We check if the mouse is over a floatingObject/ */ - floatingObjectBeingDragged = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY); + floatingObjectBeingDragged = thisObject.floatingSpace.floatingLayer.isInside(point.x, point.y); if (floatingObjectBeingDragged >= 0) { floatingObjectDragStarted = true; @@ -367,7 +367,7 @@ function newCanvas() { let point = { x: event.pageX, - y: event.pageY + y: event.pageY - window.TOP_MARGIN }; let container; @@ -404,7 +404,7 @@ function newCanvas() { /* We check if the mouse is over a floatingObject/ */ - let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY); + let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(point.x, point.y); if (floatingObjectBeingClicked >= 0) { @@ -467,14 +467,19 @@ function newCanvas() { if (INTENSIVE_LOG === true) { logger.write("[INFO] onMouseMove -> Entering function."); } - viewPort.mousePosition.x = event.pageX; - viewPort.mousePosition.y = event.pageY; + let point = { + x: event.pageX, + y: event.pageY - window.TOP_MARGIN + }; + + viewPort.mousePosition.x = point.x; + viewPort.mousePosition.y = point.y; if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) { if (floatingObjectDragStarted === true) { - if (thisObject.floatingSpace.floatingLayer.isInsideFloatingObject(floatingObjectBeingDragged, event.pageX, event.pageY) === false) { + if (thisObject.floatingSpace.floatingLayer.isInsideFloatingObject(floatingObjectBeingDragged, point.x, point.y) === false) { /* This means that the user stop moving the mouse and the floatingObject floatingObject out of the pointer. In this case we cancell the drag operation . */ @@ -486,10 +491,10 @@ function newCanvas() { } - dragVector.upX = event.pageX; - dragVector.upY = event.pageY; + dragVector.upX = point.x; + dragVector.upY = point.y; - checkDrag(); + checkDrag(event); } else { onMouseOver(event); @@ -517,7 +522,7 @@ function newCanvas() { let point = { x: event.pageX, - y: event.pageY + y: event.pageY - window.TOP_MARGIN }; let container; @@ -554,7 +559,7 @@ function newCanvas() { /* We check if the mouse is over a floatingObject/ */ - let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY); + let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(point.x, point.y); if (floatingObjectBeingClicked >= 0) { @@ -594,7 +599,12 @@ function newCanvas() { /* We try first with panels. */ - let panelContainer = canvas.panelsSpace.getContainer({ x: event.pageX, y: event.pageY }); + let point = { + x: event.pageX, + y: event.pageY - window.TOP_MARGIN + }; + + let panelContainer = canvas.panelsSpace.getContainer({ x: point.x, y: point.y }); if (panelContainer !== undefined && panelContainer.isWheelable === true) { @@ -604,7 +614,7 @@ function newCanvas() { /* We try second with floating objects. */ - let floatingObjectIndex = canvas.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY); + let floatingObjectIndex = canvas.floatingSpace.floatingLayer.isInside(point.x, point.y); if (floatingObjectIndex > 0) { @@ -614,7 +624,7 @@ function newCanvas() { /* We try the Bottom Space. */ - let bottomContainer = canvas.bottomSpace.getContainer({ x: event.pageX, y: event.pageY }); + let bottomContainer = canvas.bottomSpace.getContainer({ x: point.x, y: point.y }); if (bottomContainer !== undefined && bottomContainer.isWheeleable === true) { @@ -625,7 +635,7 @@ function newCanvas() { /* Finally we try the Chart Space. */ - let chartContainer = canvas.chartSpace.getContainer({ x: event.pageX, y: event.pageY }); + let chartContainer = canvas.chartSpace.getContainer({ x: point.x, y: point.y }); if (chartContainer !== undefined && chartContainer.isWheeleable === true) { @@ -647,7 +657,7 @@ function newCanvas() { } } - function checkDrag() { + function checkDrag(event) { try { @@ -655,10 +665,15 @@ function newCanvas() { if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) { + let point = { + x: event.pageX, + y: event.pageY - window.TOP_MARGIN + }; + browserCanvas.style.cursor = "grabbing"; thisObject.eventHandler.raiseEvent("Dragging", undefined); - let targetFloatingObject = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY); + let targetFloatingObject = thisObject.floatingSpace.floatingLayer.isInside(point.x, point.y); if (floatingObjectDragStarted) { diff --git a/Scripts/AppPreLoader.js b/Scripts/AppPreLoader.js index 977092adb..5459cc5b8 100644 --- a/Scripts/AppPreLoader.js +++ b/Scripts/AppPreLoader.js @@ -59,9 +59,11 @@ function loadAdvancedAlgosPlatform() { browserCanvas = document.getElementById('canvas'); browserCanvas.width = window.innerWidth; - browserCanvas.height = window.innerHeight; + browserCanvas.height = window.innerHeight - window.TOP_MARGIN; browserCanvas.style.border = "none"; + browserCanvas.style.top = window.TOP_MARGIN + 'px'; + /* The second thing to do is to send the tokenSession to the server, so that it can prepare the server side data structures needed. */ let sessionToken = window.SESSION_TOKEN; diff --git a/index.html b/index.html index 14438d730..71fba28ee 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,9 @@ window.SESSION_TOKEN = ''; window.EXECUTING_AT = 'Master App'; - window.URL_PREFIX = 'http://localhost:1337/'; + window.TOP_MARGIN = 85; + window.URL_PREFIX = 'http://develop.advancedalgos.net:1337/'; + //window.URL_PREFIX = 'http://localhost:1337/'; loadAdvancedAlgosPlatform(); ">