container.displacement removed, code cleanead
This commit is contained in:
1 parent
57e58da67b
commit
9d8a6415c5
8 files changed
-161
No files matched your search
@@ -31,7 +31,6 @@ function newViewPort () {
|
||||
zoomLevel: undefined,
|
||||
mousePosition: undefined,
|
||||
margins: MARGINS,
|
||||
getDisplacement: getDisplacement,
|
||||
newZoomLevel: newZoomLevel,
|
||||
applyZoom: applyZoom,
|
||||
isMinZoom: isMinZoom,
|
||||
@@ -105,14 +104,6 @@ function newViewPort () {
|
||||
thisObject.height = thisObject.visibleArea.bottomRight.y - thisObject.visibleArea.topLeft.y
|
||||
}
|
||||
|
||||
function getDisplacement () {
|
||||
let displacement = {
|
||||
x: offset.x,
|
||||
y: offset.y
|
||||
}
|
||||
return displacement
|
||||
}
|
||||
|
||||
function raiseEvents () {
|
||||
let event = {
|
||||
newOffset: offset
|
||||
|
||||
@@ -4,7 +4,6 @@ function newContainer () {
|
||||
id: Math.trunc(Math.random() * 10000000),
|
||||
type: 'Rectangle',
|
||||
frame: undefined,
|
||||
displacement: undefined,
|
||||
eventHandler: undefined,
|
||||
parentContainer: undefined,
|
||||
isDraggeable: true,
|
||||
@@ -76,10 +75,6 @@ function newContainer () {
|
||||
|
||||
thisObject.eventHandler = newEventHandler()
|
||||
thisObject.eventHandler.name = pName
|
||||
|
||||
thisObject.displacement = newDisplacement()
|
||||
thisObject.displacement.container = thisObject
|
||||
thisObject.displacement.containerName = pName
|
||||
}
|
||||
|
||||
function connectToParent (
|
||||
@@ -111,7 +106,6 @@ function newContainer () {
|
||||
|
||||
isConnectedToParent = true
|
||||
|
||||
thisObject.displacement.parentDisplacement = parentContainer.displacement
|
||||
thisObject.frame.parentFrame = parentContainer.frame
|
||||
thisObject.parentContainer = parentContainer
|
||||
|
||||
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
|
||||
/*
|
||||
|
||||
We call displacement to the offset we can produce to the object which the displcement object is is a child from.
|
||||
The displacement is a vector that displaces everything static drawn on on the context of the parent object.
|
||||
|
||||
*/
|
||||
|
||||
function newDisplacement () {
|
||||
let displacement = {
|
||||
containerName: '', // This is for debugging purposes only.
|
||||
parentDisplacement: undefined, // Here we store the displacement object of the parent cointainer, if exists.
|
||||
container: undefined,
|
||||
x: 0, // This is the actual x displacement.
|
||||
y: 0, // This is the actual y displacement.
|
||||
displace: displace,
|
||||
undisplaceThisPoint: undisplaceThisPoint,
|
||||
displaceThisPoint: displaceThisPoint
|
||||
}
|
||||
|
||||
return displacement
|
||||
|
||||
function displace (amountX, amountY) {
|
||||
/* First we check if by allowing this displacement we would produce the current frame to be beyond its limit. */
|
||||
|
||||
tempDisplacement = newDisplacement()
|
||||
tempDisplacement.x = amountX
|
||||
tempDisplacement.y = amountY
|
||||
|
||||
if (this.container.frame.canYouMoveHere(tempDisplacement)) {
|
||||
/* Now we displace */
|
||||
|
||||
displacement.x = displacement.x + amountX
|
||||
displacement.y = displacement.y + amountY
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
function displaceThisPoint (point) {
|
||||
if (this.parentDisplacement !== undefined) {
|
||||
point = this.parentDisplacement.displaceThisPoint(point)
|
||||
}
|
||||
|
||||
point.x = point.x + displacement.x
|
||||
point.y = point.y + displacement.y
|
||||
|
||||
return point
|
||||
}
|
||||
|
||||
function undisplaceThisPoint (point) {
|
||||
if (this.parentDisplacement !== undefined) {
|
||||
point = this.parentDisplacement.undisplaceThisPoint(point)
|
||||
}
|
||||
|
||||
point.x = point.x - displacement.x
|
||||
point.y = point.y - displacement.y
|
||||
|
||||
return point
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ function newFrame () {
|
||||
isThisPointHere: isThisPointHere, // This function return true is the point received as parameter lives within this frame.
|
||||
isThisScreenPointHere: isThisScreenPointHere,
|
||||
isInViewPort: isInViewPort,
|
||||
canYouMoveHere: canYouMoveHere,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
@@ -150,78 +149,6 @@ function newFrame () {
|
||||
return point
|
||||
}
|
||||
|
||||
function canYouMoveHere (tempDisplacement) {
|
||||
/*
|
||||
|
||||
The current frame has a position and a displacement. We need to check that none of the boundaries points of the frame fall outside of its container frame.
|
||||
First we apply the theoreticall displacement.
|
||||
|
||||
*/
|
||||
|
||||
point1 = {
|
||||
x: thisObject.position.x,
|
||||
y: thisObject.position.y
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.position.x + thisObject.width,
|
||||
y: thisObject.position.y
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.position.x + thisObject.width,
|
||||
y: thisObject.position.y + thisObject.height
|
||||
}
|
||||
|
||||
point4 = {
|
||||
x: thisObject.position.x,
|
||||
y: thisObject.position.y + thisObject.height
|
||||
}
|
||||
|
||||
/* Now the transformations. */
|
||||
|
||||
if (thisObject.parentFrame !== undefined) {
|
||||
// If there is not a parent then there is no point to check bounderies.
|
||||
|
||||
point1 = thisObject.parentFrame.frameThisPoint(point1)
|
||||
point2 = thisObject.parentFrame.frameThisPoint(point2)
|
||||
point3 = thisObject.parentFrame.frameThisPoint(point3)
|
||||
point4 = thisObject.parentFrame.frameThisPoint(point4)
|
||||
|
||||
/* We apply the temporary displacement. */
|
||||
|
||||
point1 = tempDisplacement.displaceThisPoint(point1)
|
||||
point2 = tempDisplacement.displaceThisPoint(point2)
|
||||
point3 = tempDisplacement.displaceThisPoint(point3)
|
||||
point4 = tempDisplacement.displaceThisPoint(point4)
|
||||
|
||||
/* We add the actual displacement. */
|
||||
|
||||
point1 = thisObject.container.displacement.displaceThisPoint(point1)
|
||||
point2 = thisObject.container.displacement.displaceThisPoint(point2)
|
||||
point3 = thisObject.container.displacement.displaceThisPoint(point3)
|
||||
point4 = thisObject.container.displacement.displaceThisPoint(point4)
|
||||
|
||||
if (thisObject.parentFrame.isThisPointHere(point1) === false) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (thisObject.parentFrame.isThisPointHere(point2) === false) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (thisObject.parentFrame.isThisPointHere(point3) === false) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (thisObject.parentFrame.isThisPointHere(point4) === false) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function isThisPointHere (point, outsideViewPort, dontTransform) {
|
||||
// The second parameter is usefull when you want to check a point that you already know is outside the viewport.
|
||||
|
||||
@@ -236,7 +163,6 @@ function newFrame () {
|
||||
in order to have the point on the containers coordinate system and be able to compare it with its dimmensions. */
|
||||
if (dontTransform === false || dontTransform === undefined) {
|
||||
if (outsideViewPort === true) {
|
||||
checkPoint = thisObject.container.displacement.undisplaceThisPoint(checkPoint)
|
||||
checkPoint = thisObject.container.frame.unframeThisPoint(checkPoint)
|
||||
} else {
|
||||
checkPoint = unTransformThisPoint(checkPoint, thisObject.container)
|
||||
|
||||
@@ -224,7 +224,6 @@ function newProductsPanel () {
|
||||
cardsMap.set(productCard.code, productCard)
|
||||
|
||||
/* Container Stuff */
|
||||
productCard.container.displacement.parentDisplacement = thisObject.container.displacement
|
||||
productCard.container.frame.parentFrame = thisObject.container.frame
|
||||
productCard.container.parentContainer = thisObject.container
|
||||
productCard.container.isWheelable = true
|
||||
|
||||
@@ -23,7 +23,6 @@ function newPanelsSpace () {
|
||||
thisObject.container = container
|
||||
thisObject.container.isDraggeable = false
|
||||
|
||||
container.displacement.containerName = 'Panels Space'
|
||||
container.frame.containerName = 'Panels Space'
|
||||
|
||||
panelsMap = new Map()
|
||||
|
||||
@@ -19,7 +19,6 @@ function newSplashScreen () {
|
||||
|
||||
resize()
|
||||
|
||||
container.displacement.containerName = 'Splash Screen'
|
||||
container.frame.containerName = 'Splash Screen'
|
||||
|
||||
container.frame.position.x = 0
|
||||
|
||||
@@ -14,10 +14,6 @@ function transformThisPoint (point, container) {
|
||||
|
||||
point = container.frame.frameThisPoint(point)
|
||||
|
||||
/* We add the possible displacement */
|
||||
|
||||
point = container.displacement.displaceThisPoint(point)
|
||||
|
||||
/* We viewport Transformation. */
|
||||
|
||||
point = viewPort.zoomThisPoint(point)
|
||||
@@ -27,7 +23,6 @@ function transformThisPoint (point, container) {
|
||||
|
||||
function unTransformThisPoint (point, container) {
|
||||
point = viewPort.unzoomThisPoint(point)
|
||||
point = container.displacement.undisplaceThisPoint(point)
|
||||
point = container.frame.unframeThisPoint(point)
|
||||
|
||||
return point
|
||||
|
||||
Reference in new issue
Block a user