Bug fixed with borders going out of viewport

This commit is contained in:
Luis Fernando Molina committed 2020-02-12 08:21:39 +01:00
1 parent 2e944c6d01
commit d96fdc7e3f
2 files changed
+38 -12

No files matched your search

+10
View File
@@ -414,6 +414,16 @@ function newEdgeEditor () {
y: pointB4.y + edgeSize
}
pointA1 = canvas.chartSpace.viewport.fitIntoViewport(pointA1)
pointA2 = canvas.chartSpace.viewport.fitIntoViewport(pointA2)
pointA3 = canvas.chartSpace.viewport.fitIntoViewport(pointA3)
pointA4 = canvas.chartSpace.viewport.fitIntoViewport(pointA4)
pointB1 = canvas.chartSpace.viewport.fitIntoViewport(pointB1)
pointB2 = canvas.chartSpace.viewport.fitIntoViewport(pointB2)
pointB3 = canvas.chartSpace.viewport.fitIntoViewport(pointB3)
pointB4 = canvas.chartSpace.viewport.fitIntoViewport(pointB4)
browserCanvasContext.setLineDash([0, 0])
browserCanvasContext.beginPath()
+28 -12
View File
@@ -36,6 +36,7 @@ function newViewport () {
isThisPointVisible: isThisPointVisible,
isThisPointInViewport: isThisPointInViewport,
fitIntoVisibleArea: fitIntoVisibleArea,
fitIntoViewport: fitIntoViewport,
displace: displace,
physics: physics,
raiseEvents: raiseEvents,
@@ -221,25 +222,40 @@ function newViewport () {
}
function fitIntoVisibleArea (point) {
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
if (point.x > thisObject.visibleArea.bottomRight.x + 1) {
point.x = thisObject.visibleArea.bottomRight.x + 1
let pointCopy = {
x: point.x,
y: point.y
}
if (point.x < thisObject.visibleArea.topLeft.x - 1) {
point.x = thisObject.visibleArea.topLeft.x - 1
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
if (pointCopy.x > thisObject.visibleArea.bottomRight.x + 1) {
pointCopy.x = thisObject.visibleArea.bottomRight.x + 1
}
if (point.y > thisObject.visibleArea.bottomRight.y + 1) {
point.y = thisObject.visibleArea.bottomRight.y + 1
if (pointCopy.x < thisObject.visibleArea.topLeft.x - 1) {
pointCopy.x = thisObject.visibleArea.topLeft.x - 1
}
if (point.y < thisObject.visibleArea.topLeft.y - 1) {
point.y = thisObject.visibleArea.topLeft.y - 1
if (pointCopy.y > thisObject.visibleArea.bottomRight.y + 1) {
pointCopy.y = thisObject.visibleArea.bottomRight.y + 1
}
return point
if (pointCopy.y < thisObject.visibleArea.topLeft.y - 1) {
pointCopy.y = thisObject.visibleArea.topLeft.y - 1
}
return pointCopy
}
function fitIntoViewport (point) {
let pointCopy = {
x: point.x,
y: point.y
}
if (pointCopy.y > COCKPIT_SPACE_POSITION) {
pointCopy.y = COCKPIT_SPACE_POSITION
}
return pointCopy
}
function displace (displaceVector, recalculate) {
@@ -320,7 +336,7 @@ function newViewport () {
}
function isThisPointInViewport (point) {
if (point.y > browserCanvas.height - COCKPIT_SPACE_POSITION) {
if (point.y > COCKPIT_SPACE_POSITION) {
return false
} else {
return true