Canvas Error Handling Improved

This commit is contained in:
Luis Fernando Molina committed 2018-06-27 13:35:17 +02:00
1 parent 00911b3dc5
commit 87ecef4c2f
2 files changed
+450 -344

No files matched your search

+445 -339
View File
@@ -8,43 +8,8 @@ let splashScreenNeeded = true;
function newCanvas() {
/*
The canvas object represents a layer on top of the browser canvas object.
Graphically, thiscanvas object has 4 spaces:
1) The "Top Space": It is where Team and User information is displayed.
2) The "Chart Space": It is where the charts are plotted.
3) The "Floating Space": It is where floating elements live. There is a physics engine for this layer that allows these elements to flow.
4) The "Panels Space": It is where panels live. --> This space has yet to be develop, currently pannels are somehow at the Chart Space.
5) The "Bottom Space": Includes the breakpoint bar and a toolbar.
All these spaces are child objects of the Canvas object.
Canvas
|
|
---> topSpace
|
|
---> chartSpace
|
|
---> flaotingSpace
|
|
---> panelsSpace
|
|
---> bottomSpace
*/
const MODULE_NAME = "Canvas";
const INFO_LOG = false;
const INFO_LOG = true;
const ERROR_LOG = true;
const logger = newWebDebugLog();
logger.fileName = MODULE_NAME;
@@ -83,437 +48,578 @@ function newCanvas() {
return thisObject;
/*
The canvas object represents a layer on top of the browser canvas object.
Graphically, thiscanvas object has 4 spaces:
1. The "Top Space": It is where Team and User information is displayed.
2. The "Chart Space": It is where the charts are plotted.
3. The "Floating Space": It is where floating elements live. There is a physics engine for this layer that allows these elements to flow.
4. The "Panels Space": It is where panels live. --> This space has yet to be develop, currently pannels are somehow at the Chart Space.
5. The "Bottom Space": Includes the breakpoint bar and a toolbar.
All these spaces are child objects of the Canvas object.
Canvas
|
|
---> topSpace
|
|
---> chartSpace
|
|
---> flaotingSpace
|
|
---> panelsSpace
|
|
---> bottomSpace
*/
function initialize(callBackFunction) {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
try {
initializeBrowserCanvas();
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
addCanvasEvents();
initializeBrowserCanvas();
/* Instantiate all the children spaces of Canvas object */
addCanvasEvents();
thisObject.topSpace = newTopSpace();
thisObject.topSpace.initialize();
/* Instantiate all the children spaces of Canvas object */
thisObject.panelsSpace = newPanelsSpace();
thisObject.panelsSpace.initialize();
thisObject.topSpace = newTopSpace();
thisObject.topSpace.initialize();
thisObject.floatingSpace = newFloatingSpace();
thisObject.floatingSpace.initialize();
thisObject.panelsSpace = newPanelsSpace();
thisObject.panelsSpace.initialize();
thisObject.chartSpace = newChartSpace();
thisObject.chartSpace.initialize(onCharSpaceInitialized);
thisObject.floatingSpace = newFloatingSpace();
thisObject.floatingSpace.initialize();
thisObject.bottomSpace = newBottomSpace();
thisObject.bottomSpace.initialize();
thisObject.chartSpace = newChartSpace();
thisObject.chartSpace.initialize(onCharSpaceInitialized);
function onCharSpaceInitialized(err) {
viewPort.raiseEvents(); // These events will impacts on objects just initialized.
}
thisObject.bottomSpace = newBottomSpace();
thisObject.bottomSpace.initialize();
/* Splash Screen */
function onCharSpaceInitialized(err) {
splashScreen = newSplashScreen();
splashScreen.initialize();
try {
let animation = newAnimation();
animation.initialize(onAnimationInitialized);
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCharSpaceInitialized -> Entering function."); }
function onAnimationInitialized(err) {
viewPort.raiseEvents(); // These events will impacts on objects just initialized.
thisObject.animation = animation;
} catch (err) {
/* Here we add all the functions that will be called during the animation cycle. */
animation.addCallBackFunction("Chart Space", thisObject.chartSpace.draw, onFunctionAdded);
animation.addCallBackFunction("Floating Space", thisObject.floatingSpace.floatingLayer.physicsLoop, onFunctionAdded);
animation.addCallBackFunction("Panels Space", thisObject.panelsSpace.draw, onFunctionAdded);
animation.addCallBackFunction("Splash Screen", splashScreen.draw, onFunctionAdded);
animation.addCallBackFunction("ViewPort Animate", viewPort.animate, onFunctionAdded);
animation.addCallBackFunction("ViewPort Draw", viewPort.draw, onFunctionAdded);
animation.addCallBackFunction("Bottom Space", thisObject.bottomSpace.draw, onFunctionAdded);
animation.addCallBackFunction("Top Space", thisObject.topSpace.draw, onFunctionAdded);
animation.start(onStart);
function onFunctionAdded(err) {
if (err.result === GLOBAL.DEFAULT_FAIL_RESPONSE.result) {
animation.stop();
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onAnimationInitialized -> onFunctionAdded -> Animation Stopped since a vital funtion could not be added."); }
/* Display some Error Page here. */
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onCharSpaceInitialized -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
function onStart(err) {
/* Splash Screen */
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
splashScreen = newSplashScreen();
splashScreen.initialize();
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onStart -> Received OK Response."); }
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
return;
let animation = newAnimation();
animation.initialize(onAnimationInitialized);
function onAnimationInitialized(err) {
try {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> Entering function."); }
thisObject.animation = animation;
/* Here we add all the functions that will be called during the animation cycle. */
animation.addCallBackFunction("Chart Space", thisObject.chartSpace.draw, onFunctionAdded);
animation.addCallBackFunction("Floating Space", thisObject.floatingSpace.floatingLayer.physicsLoop, onFunctionAdded);
animation.addCallBackFunction("Panels Space", thisObject.panelsSpace.draw, onFunctionAdded);
animation.addCallBackFunction("Splash Screen", splashScreen.draw, onFunctionAdded);
animation.addCallBackFunction("ViewPort Animate", viewPort.animate, onFunctionAdded);
animation.addCallBackFunction("ViewPort Draw", viewPort.draw, onFunctionAdded);
animation.addCallBackFunction("Bottom Space", thisObject.bottomSpace.draw, onFunctionAdded);
animation.addCallBackFunction("Top Space", thisObject.topSpace.draw, onFunctionAdded);
animation.start(onStart);
function onFunctionAdded(err) {
try {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onFunctionAdded -> Entering function."); }
if (err.result === GLOBAL.DEFAULT_FAIL_RESPONSE.result) {
animation.stop();
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onAnimationInitialized -> onFunctionAdded -> Animation Stopped since a vital funtion could not be added."); }
/* Display some Error Page here. */
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onAnimationInitialized -> onFunctionAdded -> -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
function onStart(err) {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onStart -> Received FAIL Response."); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
return;
try {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onStart -> Entering function."); }
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onStart -> Received OK Response."); }
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
return;
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onStart -> Received FAIL Response."); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
return;
}
default: {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onStart -> Received Unexpected Response."); }
callBackFunction(err);
return;
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onAnimationInitialized -> onStart -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
default: {
} catch (err) {
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onAnimationInitialized -> onStart -> Received Unexpected Response."); }
callBackFunction(err);
return;
}
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onAnimationInitialized -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
}
}
function initializeBrowserCanvas() {
if (INFO_LOG === true) { logger.write("[INFO] initializeBrowserCanvas -> Entering function."); }
try {
browserCanvas = document.getElementById('canvas');
browserCanvasContext = browserCanvas.getContext('2d');
if (INFO_LOG === true) { logger.write("[INFO] initializeBrowserCanvas -> Entering function."); }
let body = document.getElementById('body');
browserCanvas = document.getElementById('canvas');
browserCanvasContext = browserCanvas.getContext('2d');
browserCanvas.width = window.innerWidth;
browserCanvas.height = window.innerHeight;
browserCanvas.style.border = "none";
let body = document.getElementById('body');
viewPort.initialize();
browserCanvas.width = window.innerWidth;
browserCanvas.height = window.innerHeight;
browserCanvas.style.border = "none";
viewPort.initialize();
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] initializeBrowserCanvas -> err = " + err); }
}
}
function addCanvasEvents() {
if (INFO_LOG === true) { logger.write("[INFO] addCanvasEvents -> Entering function."); }
try {
/* Mouse down and up events to control the drag of the canvas. */
if (INFO_LOG === true) { logger.write("[INFO] addCanvasEvents -> Entering function."); }
browserCanvas.addEventListener('mousedown', onMouseDown, false);
browserCanvas.addEventListener('mouseup', onMouseUp, false);
browserCanvas.addEventListener('mousemove', onMouseMove, false);
browserCanvas.addEventListener('click', onMouseClick, false);
/* Mouse down and up events to control the drag of the canvas. */
/* Mouse wheel events. */
browserCanvas.addEventListener('mousedown', onMouseDown, false);
browserCanvas.addEventListener('mouseup', onMouseUp, false);
browserCanvas.addEventListener('mousemove', onMouseMove, false);
browserCanvas.addEventListener('click', onMouseClick, false);
if (browserCanvas.addEventListener) {
// IE9, Chrome, Safari, Opera
browserCanvas.addEventListener("mousewheel", onMouseWheel, false);
// Firefox
browserCanvas.addEventListener("DOMMouseScroll", onMouseWheel, false);
/* Mouse wheel events. */
if (browserCanvas.addEventListener) {
// IE9, Chrome, Safari, Opera
browserCanvas.addEventListener("mousewheel", onMouseWheel, false);
// Firefox
browserCanvas.addEventListener("DOMMouseScroll", onMouseWheel, false);
}
// IE 6/7/8
else browserCanvas.attachEvent("onmousewheel", onMouseWheel);
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] addCanvasEvents -> err = " + err); }
}
// IE 6/7/8
else browserCanvas.attachEvent("onmousewheel", onMouseWheel);
}
function onMouseDown(event) {
if (INFO_LOG === true) { logger.write("[INFO] onMouseDown -> Entering function."); }
try {
/*
if (INFO_LOG === true) { logger.write("[INFO] onMouseDown -> Entering function."); }
There are four types of elements that can be dragged.
/*
There are four types of elements that can be dragged.
1. Panels.
2. Floating Elements (Currently only FloatingObjects).
3. Charts.
4. The Viewport.
We eveluate each space in order to see if they are holding the element being dragged, and we fallout at the Viewport.
*/
1. Panels.
2. Floating Elements (Currently only FloatingObjects).
3. Charts.
4. The Viewport.
dragVector.downX = event.pageX;
dragVector.downY = event.pageY;
We eveluate each space in order to see if they are holding the element being dragged, and we fallout at the Viewport.
let point = {
x: event.pageX,
y: event.pageY
};
*/
let container;
dragVector.downX = event.pageX;
dragVector.downY = event.pageY;
/* We check if the mouse is over an element of the Top Space / */
let point = {
x: event.pageX,
y: event.pageY
};
container = thisObject.topSpace.getContainer(point);
let container;
if (container !== undefined && container.isDraggeable === true) {
/* We check if the mouse is over an element of the Top Space / */
containerBeingDragged = container;
containerDragStarted = true;
return;
}
container = thisObject.topSpace.getContainer(point);
/* We check if the mouse is over an element of the Bottom Space / */
if (container !== undefined && container.isDraggeable === true) {
container = thisObject.bottomSpace.getContainer(point);
if (container !== undefined && container.isDraggeable === true) {
containerBeingDragged = container;
containerDragStarted = true;
return;
}
/* We check if the mouse is over a panel/ */
container = thisObject.panelsSpace.getContainer(point);
if (container !== undefined && container.isDraggeable === true) {
containerBeingDragged = container;
containerDragStarted = true;
return;
}
/* We check if the mouse is over a floatingObject/ */
floatingObjectBeingDragged = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
if (floatingObjectBeingDragged >= 0) {
floatingObjectDragStarted = true;
return;
}
/* If it is not, then we check if it is over any of the existing containers at the Chart Space. */
container = thisObject.chartSpace.getContainer(point);
if (container !== undefined && container.isDraggeable === true) {
containerBeingDragged = container;
containerDragStarted = true;
return;
}
viewPortBeingDragged = true;
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onMouseDown -> err = " + err); }
containerBeingDragged = container;
containerDragStarted = true;
return;
}
/* We check if the mouse is over an element of the Bottom Space / */
container = thisObject.bottomSpace.getContainer(point);
if (container !== undefined && container.isDraggeable === true) {
containerBeingDragged = container;
containerDragStarted = true;
return;
}
/* We check if the mouse is over a panel/ */
container = thisObject.panelsSpace.getContainer(point);
if (container !== undefined && container.isDraggeable === true) {
containerBeingDragged = container;
containerDragStarted = true;
return;
}
/* We check if the mouse is over a floatingObject/ */
floatingObjectBeingDragged = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
if (floatingObjectBeingDragged >= 0) {
floatingObjectDragStarted = true;
return;
}
/* If it is not, then we check if it is over any of the existing containers at the Chart Space. */
container = thisObject.chartSpace.getContainer(point);
if (container !== undefined && container.isDraggeable === true) {
containerBeingDragged = container;
containerDragStarted = true;
return;
}
viewPortBeingDragged = true;
}
function onMouseClick(event) {
if (INFO_LOG === true) { logger.write("[INFO] onMouseClick -> Entering function."); }
try {
let point = {
x: event.pageX,
y: event.pageY
};
if (INFO_LOG === true) { logger.write("[INFO] onMouseClick -> Entering function."); }
let container;
let point = {
x: event.pageX,
y: event.pageY
};
/* We check if the mouse is over an element of the Top Space / */
let container;
container = thisObject.topSpace.getContainer(point);
/* We check if the mouse is over an element of the Top Space / */
if (container !== undefined && container.isClickeable === true) {
container = thisObject.topSpace.getContainer(point);
if (container !== undefined && container.isClickeable === true) {
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
/* We check if the mouse is over an element of the Bottom Space / */
container = thisObject.bottomSpace.getContainer(point);
if (container !== undefined && container.isClickeable === true) {
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
/* We check if the mouse is over a panel/ */
container = thisObject.panelsSpace.getContainer(point);
if (container !== undefined && container.isClickeable === true) {
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
/* We check if the mouse is over a floatingObject/ */
let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
if (floatingObjectBeingClicked >= 0) {
/* Right now we do nothing with this. */
return;
}
/* If it is not, then we check if it is over any of the existing containers at the Chart Space. */
container = thisObject.chartSpace.getContainer(point);
if (container !== undefined && container.isClickeable === true) {
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onMouseClick -> err = " + err); }
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
/* We check if the mouse is over an element of the Bottom Space / */
container = thisObject.bottomSpace.getContainer(point);
if (container !== undefined && container.isClickeable === true) {
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
/* We check if the mouse is over a panel/ */
container = thisObject.panelsSpace.getContainer(point);
if (container !== undefined && container.isClickeable === true) {
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
/* We check if the mouse is over a floatingObject/ */
let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
if (floatingObjectBeingClicked >= 0) {
/* Right now we do nothing with this. */
return;
}
/* If it is not, then we check if it is over any of the existing containers at the Chart Space. */
container = thisObject.chartSpace.getContainer(point);
if (container !== undefined && container.isClickeable === true) {
container.eventHandler.raiseEvent('onMouseClick', point);
return;
}
}
function onMouseUp(event) {
if (INFO_LOG === true) { logger.write("[INFO] onMouseUp -> Entering function."); }
try {
if (containerDragStarted || viewPortBeingDragged || floatingObjectDragStarted) {
if (INFO_LOG === true) { logger.write("[INFO] onMouseUp -> Entering function."); }
thisObject.eventHandler.raiseEvent("Drag Finished", undefined);
if (containerDragStarted || viewPortBeingDragged || floatingObjectDragStarted) {
thisObject.eventHandler.raiseEvent("Drag Finished", undefined);
}
/* Turn off all the possible things that can be dragged. */
containerDragStarted = false;
floatingObjectDragStarted = false;
viewPortBeingDragged = false;
containerBeingDragged = undefined;
browserCanvas.style.cursor = "auto";
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onMouseUp -> err = " + err); }
}
/* Turn off all the possible things that can be dragged. */
containerDragStarted = false;
floatingObjectDragStarted = false;
viewPortBeingDragged = false;
containerBeingDragged = undefined;
browserCanvas.style.cursor = "auto";
}
function onMouseMove(event) {
if (INFO_LOG === true) { logger.write("[INFO] onMouseMove -> Entering function."); }
try {
viewPort.mousePosition.x = event.pageX;
viewPort.mousePosition.y = event.pageY;
if (INFO_LOG === true) { logger.write("[INFO] onMouseMove -> Entering function."); }
if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) {
viewPort.mousePosition.x = event.pageX;
viewPort.mousePosition.y = event.pageY;
if (floatingObjectDragStarted === true) {
if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) {
if (thisObject.floatingSpace.floatingLayer.isInsideFloatingObject(floatingObjectBeingDragged, event.pageX, event.pageY) === false) {
if (floatingObjectDragStarted === true) {
/* 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 . */
if (thisObject.floatingSpace.floatingLayer.isInsideFloatingObject(floatingObjectBeingDragged, event.pageX, event.pageY) === 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 . */
floatingObjectDragStarted = false;
browserCanvas.style.cursor = "auto";
return;
}
floatingObjectDragStarted = false;
browserCanvas.style.cursor = "auto";
return;
}
dragVector.upX = event.pageX;
dragVector.upY = event.pageY;
checkDrag();
}
dragVector.upX = event.pageX;
dragVector.upY = event.pageY;
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onMouseMove -> err = " + err); }
checkDrag();
}
}
function onMouseWheel(event) {
if (INFO_LOG === true) { logger.write("[INFO] onMouseWheel -> Entering function."); }
try {
// cross-browser wheel delta
var event = window.event || event; // old IE support
let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail));
if (INFO_LOG === true) { logger.write("[INFO] onMouseWheel -> Entering function."); }
/* We try first with panels. */
// cross-browser wheel delta
var event = window.event || event; // old IE support
let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail));
let panelContainer = canvas.panelsSpace.getContainer({ x: event.pageX, y: event.pageY });
/* We try first with panels. */
if (panelContainer !== undefined && panelContainer.isWheelable === true) {
let panelContainer = canvas.panelsSpace.getContainer({ x: event.pageX, y: event.pageY });
if (panelContainer !== undefined && panelContainer.isWheelable === true) {
panelContainer.eventHandler.raiseEvent("Mouse Wheel", event.wheelDelta);
return false; // This instructs the browser not to take the event and scroll the page.
}
/* We try second with floating objects. */
let floatingObjectIndex = canvas.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
if (floatingObjectIndex > 0) {
canvas.floatingSpace.floatingLayer.changeTargetRepulsion(event.wheelDelta);
} else {
viewPort.applyZoom(delta);
}
panelContainer.eventHandler.raiseEvent("Mouse Wheel", event.wheelDelta);
return false; // This instructs the browser not to take the event and scroll the page.
}
/* We try second with floating objects. */
} catch (err) {
let floatingObjectIndex = canvas.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
if (floatingObjectIndex > 0) {
canvas.floatingSpace.floatingLayer.changeTargetRepulsion(event.wheelDelta);
} else {
viewPort.applyZoom(delta);
if (ERROR_LOG === true) { logger.write("[ERROR] onMouseWheel -> err = " + err); }
}
return false; // This instructs the browser not to take the event and scroll the page.
}
function checkDrag() {
if (INFO_LOG === true) { logger.write("[INFO] checkDrag -> Entering function."); }
try {
if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) {
if (INFO_LOG === true) { logger.write("[INFO] checkDrag -> Entering function."); }
browserCanvas.style.cursor = "grabbing";
thisObject.eventHandler.raiseEvent("Dragging", undefined);
if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) {
let targetFloatingObject = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
browserCanvas.style.cursor = "grabbing";
thisObject.eventHandler.raiseEvent("Dragging", undefined);
if (floatingObjectDragStarted) {
let targetFloatingObject = thisObject.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
let floatingObject = thisObject.floatingSpace.floatingLayer.getFloatingObject(undefined, floatingObjectBeingDragged);
if (floatingObjectDragStarted) {
floatingObject.currentPosition.x = dragVector.upX;
floatingObject.currentPosition.y = dragVector.upY;
let floatingObject = thisObject.floatingSpace.floatingLayer.getFloatingObject(undefined, floatingObjectBeingDragged);
floatingObject.currentPosition.x = dragVector.upX;
floatingObject.currentPosition.y = dragVector.upY;
}
if (containerDragStarted || viewPortBeingDragged) {
/* The parameters received have been captured with zoom applied. We must remove the zoom in order to correctly modify the displacement. */
let downCopy = {
x: dragVector.downX,
y: dragVector.downY
};
let downCopyNoTransf;
downCopyNoTransf = viewPort.unzoomThisPoint(downCopy);
//downCopyNoTransf = containerBeingDragged.zoom.unzoomThisPoint(downCopyNoTransf);
let upCopy = {
x: dragVector.upX,
y: dragVector.upY
};
let upCopyNoTranf;
upCopyNoTranf = viewPort.unzoomThisPoint(upCopy);
let displaceVector = {
x: dragVector.upX - dragVector.downX,
y: dragVector.upY - dragVector.downY
};
if (viewPortBeingDragged) {
viewPort.displace(displaceVector);
}
if (containerBeingDragged !== undefined) {
containerBeingDragged.frame.position.x = containerBeingDragged.frame.position.x + displaceVector.x;
containerBeingDragged.frame.position.y = containerBeingDragged.frame.position.y + displaceVector.y;
}
}
/* Finally we set the starting point of the new dragVector at this current point. */
dragVector.downX = dragVector.upX;
dragVector.downY = dragVector.upY;
}
if (containerDragStarted || viewPortBeingDragged) {
} catch (err) {
/* The parameters received have been captured with zoom applied. We must remove the zoom in order to correctly modify the displacement. */
let downCopy = {
x: dragVector.downX,
y: dragVector.downY
};
let downCopyNoTransf;
downCopyNoTransf = viewPort.unzoomThisPoint(downCopy);
//downCopyNoTransf = containerBeingDragged.zoom.unzoomThisPoint(downCopyNoTransf);
let upCopy = {
x: dragVector.upX,
y: dragVector.upY
};
let upCopyNoTranf;
upCopyNoTranf = viewPort.unzoomThisPoint(upCopy);
let displaceVector = {
x: dragVector.upX - dragVector.downX,
y: dragVector.upY - dragVector.downY
};
if (viewPortBeingDragged) {
viewPort.displace(displaceVector);
}
if (containerBeingDragged !== undefined) {
containerBeingDragged.frame.position.x = containerBeingDragged.frame.position.x + displaceVector.x;
containerBeingDragged.frame.position.y = containerBeingDragged.frame.position.y + displaceVector.y;
}
}
/* Finally we set the starting point of the new dragVector at this current point. */
dragVector.downX = dragVector.upX;
dragVector.downY = dragVector.upY;
if (ERROR_LOG === true) { logger.write("[ERROR] checkDrag -> err = " + err); }
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
/* These 2 are global variables, that is why they do not have a let or var */
CONSOLE_LOG = false;
CONSOLE_LOG = true;
LOG_FILE_CONTENT = false;
if (CONSOLE_LOG === true) { console.log("[INFO] server -> Node Server Starting."); }
@@ -1021,7 +1021,7 @@ function respondWithContent(content, response) {
}
catch (err) {
returnEmptyArray();
returnEmptyArray(response);
}
}
@@ -1052,9 +1052,9 @@ function respondWithFile(fileName, response) {
//console.log("File Sent: " + fileName);
//
}
catch (err) {
returnEmptyArray();
catch (err) {
console.log("[ERROR] server -> respondWithFile -> onFileRead -> File Not Found: " + fileName + " or Error = " + err);
returnEmptyArray();
}
}
@@ -1100,7 +1100,7 @@ function respondWithImage(fileName, response) {
}
}
function returnEmptyArray() {
function returnEmptyArray(response) {
try {