Bug fixed: moving a closed space

This commit is contained in:
Luis Fernando Molina committed 2020-03-03 16:07:36 +01:00
1 parent 89cdbe3105
commit 71a5cda325
2 files changed
+26 -5

No files matched your search

+10
View File
@@ -20,6 +20,7 @@ function newViewport () {
}
let thisObject = {
visible: false,
visibleArea: undefined,
width: undefined,
height: undefined,
@@ -128,6 +129,7 @@ function newViewport () {
}
function raiseEvents () {
if (thisObject.visible === false) { return }
let event = {
newPosition: position
}
@@ -136,12 +138,14 @@ function newViewport () {
}
function physics () {
if (thisObject.visible === false) { return }
animationPhysics()
positioningPhysics()
readObjectState()
}
function positioningPhysics () {
if (thisObject.visible === false) { return }
if (thisObject.payload === undefined) { return }
/* Save the position at the frame lavel */
let frame = {}
@@ -176,6 +180,7 @@ function newViewport () {
}
function onMouseWheel (event) {
if (thisObject.visible === false) { return }
if ((event.ctrlKey === true || event.metaKey === true)) { return }
let morePower = 1
let amount = event.delta
@@ -259,6 +264,7 @@ function newViewport () {
}
function displace (displaceVector, recalculate) {
if (thisObject.visible === false) { return }
position.x = position.x + displaceVector.x
position.y = position.y + displaceVector.y
@@ -273,6 +279,7 @@ function newViewport () {
}
function changeZoom (oldLevel, newLevel) {
if (thisObject.visible === false) { return }
let oldMouse = unTransformThisPoint(thisObject.mousePosition, oldLevel)
let newMouse = transformThisPoint(oldMouse, newLevel)
@@ -295,6 +302,7 @@ function newViewport () {
}
function transformThisPoint (point, level) {
if (thisObject.visible === false) { return }
let transformedPoint = {
x: 0,
y: 0
@@ -328,6 +336,7 @@ function newViewport () {
}
function isThisPointVisible (point) {
if (thisObject.visible === false) { return }
if (point.x < thisObject.visibleArea.topLeft.x || point.x > thisObject.visibleArea.bottomRight.x || point.y < thisObject.visibleArea.topLeft.y || point.y > thisObject.visibleArea.bottomRight.y) {
return false
} else {
@@ -336,6 +345,7 @@ function newViewport () {
}
function isThisPointInViewport (point) {
if (thisObject.visible === false) { return }
if (point.y > COCKPIT_SPACE_POSITION) {
return false
} else {
+16 -5
View File
@@ -13,7 +13,7 @@ function newChartingSpace () {
logger.fileName = MODULE_NAME
let thisObject = {
visible: undefined,
visible: false,
container: undefined,
inViewport: undefined,
timeMachines: undefined,
@@ -170,6 +170,7 @@ function newChartingSpace () {
}
function oneScreenUp () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: 0,
y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
@@ -179,6 +180,7 @@ function newChartingSpace () {
}
function oneScreenDown () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: 0,
y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100
@@ -188,6 +190,7 @@ function newChartingSpace () {
}
function oneScreenLeft () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
@@ -197,6 +200,7 @@ function newChartingSpace () {
}
function oneScreenRight () {
if (thisObject.visible === false) { return }
let displaceVector = {
x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100,
y: 0
@@ -259,11 +263,11 @@ function newChartingSpace () {
}
function physics () {
thisObjectPhysics()
if (thisObject.visible !== true) { return }
if (thisObject.viewport !== undefined) {
thisObject.viewport.physics()
}
thisObjectPhysics()
childrenPhysics()
syncWithDesigner()
}
@@ -345,10 +349,16 @@ function newChartingSpace () {
function thisObjectPhysics () {
thisObject.container.frame.height = COCKPIT_SPACE_POSITION
if (thisObject.container.frame.height <= 0 / 100) {
if (thisObject.container.frame.height <= TOP_SPACE_HEIGHT) {
thisObject.visible = false
if (thisObject.viewport !== undefined) {
thisObject.viewport.visible = false
}
} else {
thisObject.visible = true
if (thisObject.viewport !== undefined) {
thisObject.viewport.visible = true
}
}
if (canvas.chartingSpace.viewport !== undefined) {
@@ -373,6 +383,7 @@ function newChartingSpace () {
}
function drawBackground () {
if (thisObject.visible === false) { return }
drawSpaceBackground()
for (let i = 0; i < thisObject.timeMachines.length; i++) {
@@ -382,7 +393,7 @@ function newChartingSpace () {
}
function draw () {
if (thisObject.visible !== true) { return }
if (thisObject.visible === false) { return }
drawBackground()
for (let i = 0; i < thisObject.timeMachines.length; i++) {