Code Cleaning
This commit is contained in:
1 parent
3e09a0009c
commit
31d47ce6f4
6 files changed
+1
-287
No files matched your search
Binary file not shown.
@@ -1,12 +0,0 @@
|
||||
|
||||
function updateBallsTargets() {
|
||||
|
||||
/* Whenever there is a change in the currentZoom level, all targets needs to be recalculated in order to fit in the new timeLineCoordinateSystem. */
|
||||
|
||||
for (var i = 0; i < balls.length; i++) {
|
||||
|
||||
balls[i].updateMass();
|
||||
balls[i].updateRadius();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -365,38 +365,7 @@ function newCanvas() {
|
||||
var event = window.event || event; // old IE support
|
||||
let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail));
|
||||
|
||||
let ballIndex = thisObject.floatingSpace.isInside(event.pageX, event.pageY);
|
||||
|
||||
if (ballIndex >= 0) {
|
||||
|
||||
/* We need to apply the Radius zoom to the cointainer of the ball where the zoom was made, for that reason, we need the ball. */
|
||||
|
||||
// balls[ballIndex].container.zoom.rZoom(delta); // Zoom is applied to ball radius.
|
||||
|
||||
} else {
|
||||
|
||||
/* We check if the mouse is over any of the existing containers. */
|
||||
|
||||
let point = {
|
||||
x: event.pageX,
|
||||
y: event.pageY
|
||||
};
|
||||
|
||||
/*
|
||||
var container = canvas.chartSpace.getContainer(point);
|
||||
|
||||
if (container !== undefined && container.isZoomeable === true) {
|
||||
|
||||
if (container.zoom.xyZoom(delta) === true) {
|
||||
|
||||
updateBallsTargets();
|
||||
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
viewPort.applyZoom(delta);
|
||||
}
|
||||
viewPort.applyZoom(delta);
|
||||
|
||||
return false; // This instructs the browser not to take the event and scroll the page.
|
||||
}
|
||||
@@ -485,24 +454,6 @@ function newCanvas() {
|
||||
containerBeingDragged.frame.position.y = containerBeingDragged.frame.position.y + displaceVector.y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (containerBeingDragged.displacement.displace(diffX, diffY) === true) {
|
||||
|
||||
updateBallsTargets(); // TODO: this should not be here
|
||||
|
||||
} else
|
||||
{
|
||||
// If the displacement can not be performed, then we dont abort the dragging operation, just allow the user to move the mouse in some other direction.
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Finally we set the starting point of the new dragVector at this current point. */
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<Compile Include="Animation.js" />
|
||||
<Compile Include="Azure\azure-storage.blob.js" />
|
||||
<Compile Include="FloatingObject.js" />
|
||||
<Compile Include="Balls.js" />
|
||||
<Compile Include="CompetitionStorage.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -121,7 +120,6 @@
|
||||
<Compile Include="Utilities.js" />
|
||||
<Compile Include="ViewPort.js" />
|
||||
<Compile Include="VolumeBar.js" />
|
||||
<Compile Include="Zoom.js" />
|
||||
<Content Include="index.html" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
/* The Zoom is the factor that amplifies the current container coordinates, and everything included in that container. */
|
||||
|
||||
|
||||
function newZoom() {
|
||||
|
||||
var zoom = {
|
||||
containerName: "", // This is for debugging purposes only.
|
||||
parentZoom: undefined, // Here we store the parent cointainer zoom object.
|
||||
container: undefined,
|
||||
levelX: 0, // this is the actual zoom level on the x axis.
|
||||
incrementX: 0.1,
|
||||
levelY: 0,
|
||||
incrementY: 0.1,
|
||||
levelR: -15,
|
||||
incrementR: 0.05,
|
||||
levelM: -15,
|
||||
incrementM: 0.05,
|
||||
xyZoom: xyZoom,
|
||||
xZoom: xZoom,
|
||||
yZoom: yZoom,
|
||||
rZoom: rZoom,
|
||||
mZoom: mZoom,
|
||||
zoomThisPoint: zoomThisPoint,
|
||||
unzoomThisPoint: unzoomThisPoint,
|
||||
stack: stack,
|
||||
level: level
|
||||
|
||||
};
|
||||
|
||||
return zoom;
|
||||
|
||||
function xyZoom(amount) {
|
||||
|
||||
var tempZoom = newZoom();
|
||||
tempZoom.levelX = this.levelX + amount;
|
||||
tempZoom.levelY = this.levelY + amount;
|
||||
tempZoom.container = this.container;
|
||||
tempZoom.parentZoom = this.parentZoom;
|
||||
|
||||
if (this.container.frame.canYouZoomHere(tempZoom)) {
|
||||
|
||||
/* Now we displace */
|
||||
|
||||
this.levelX = this.levelX + amount;
|
||||
this.levelY = this.levelY + amount;
|
||||
|
||||
if (this.levelX < -50) {
|
||||
this.levelX = -50; // There is a minimun zoom level.
|
||||
}
|
||||
|
||||
if (this.levelY < -50) {
|
||||
this.levelY = -50; // There is a minimun zoom level.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function xZoom(amount) {
|
||||
|
||||
this.levelX = this.levelX + amount;
|
||||
|
||||
if (this.levelX < -10) {
|
||||
this.levelX = -10; // There is a minimun zoom level.
|
||||
}
|
||||
updateBallsTargets();
|
||||
|
||||
}
|
||||
|
||||
function yZoom(amount) {
|
||||
|
||||
this.levelY = this.levelY + amount;
|
||||
|
||||
if (this.levelY < -10) {
|
||||
this.levelY = -10; // There is a minimun zoom level.
|
||||
}
|
||||
updateBallsTargets();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function rZoom(amount) {
|
||||
|
||||
this.levelR = this.levelR + amount;
|
||||
|
||||
var zoomLimit = - 1 / this.incrementR;
|
||||
|
||||
if (zoom.levelR <= zoomLimit + 1) {
|
||||
zoom.levelR = zoomLimit + 2; // There is a minimun zoom level.
|
||||
}
|
||||
updateBallsTargets();
|
||||
|
||||
}
|
||||
|
||||
function mZoom(amount) {
|
||||
|
||||
this.levelM = this.levelM + amount;
|
||||
|
||||
var zoomLimit = - 1 / this.incrementM;
|
||||
|
||||
if (zoom.levelM <= zoomLimit + 1) {
|
||||
zoom.levelM = zoomLimit + 2; // There is a minimun zoom level.
|
||||
}
|
||||
updateBallsTargets();
|
||||
|
||||
}
|
||||
|
||||
function zoomThisPoint(point) {
|
||||
|
||||
if (this.parentZoom !== undefined) {
|
||||
|
||||
point = this.parentZoom.zoomThisPoint(point);
|
||||
|
||||
}
|
||||
|
||||
/* The zoom center is needed to calculate the zoom for each point within this container. */
|
||||
|
||||
zoomAxisCenter = {
|
||||
x: this.container.frame.width / 2,
|
||||
y: this.container.frame.height / 2
|
||||
}
|
||||
|
||||
/* Guess what? yes, the axis center itself must be framed and displaced before being used.*/
|
||||
|
||||
zoomAxisCenter = this.container.frame.frameThisPoint(zoomAxisCenter);
|
||||
zoomAxisCenter = this.container.displacement.displaceThisPoint(zoomAxisCenter);
|
||||
|
||||
var diffX = point.x - zoomAxisCenter.x ;
|
||||
|
||||
point.x = zoomAxisCenter.x + diffX + diffX * this.incrementX * this.levelX;
|
||||
|
||||
var diffY = point.y - zoomAxisCenter.y;
|
||||
|
||||
point.y = zoomAxisCenter.y + diffY + diffY * this.incrementY * this.levelY;
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
function unzoomThisPoint(pointWithZoom) {
|
||||
|
||||
if (this.parentZoom !== undefined) {
|
||||
|
||||
pointWithZoom = this.parentZoom.unzoomThisPoint(pointWithZoom);
|
||||
|
||||
}
|
||||
|
||||
/* The zoom center is needed to calculate the zoom for each point within this container. */
|
||||
|
||||
zoomAxisCenter = {
|
||||
x: this.container.frame.width / 2,
|
||||
y: this.container.frame.height / 2
|
||||
}
|
||||
|
||||
/* Guess what? yes, the axis center itself must be framed and displaced before being used.*/
|
||||
|
||||
zoomAxisCenter = this.container.frame.frameThisPoint(zoomAxisCenter);
|
||||
zoomAxisCenter = this.container.displacement.displaceThisPoint(zoomAxisCenter);
|
||||
|
||||
var pointWithoutZoom = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
pointWithoutZoom.x = (pointWithZoom.x - zoomAxisCenter.x) / (1 + this.incrementX * this.levelX) + zoomAxisCenter.x;
|
||||
pointWithoutZoom.y = (pointWithZoom.y - zoomAxisCenter.y) / (1 + this.incrementY * this.levelY) + zoomAxisCenter.y;
|
||||
|
||||
return pointWithoutZoom;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function level() {
|
||||
|
||||
/* This function provides a sense of the zoom level all through the stack of containers object's zoom. */
|
||||
|
||||
var fullLevel = 0;
|
||||
|
||||
if (this.parentZoom !== undefined) {
|
||||
|
||||
fullLevel = this.parentZoom.level();
|
||||
|
||||
}
|
||||
|
||||
fullLevel = fullLevel + (this.levelX + this.levelY) / 2;
|
||||
|
||||
return fullLevel;
|
||||
}
|
||||
|
||||
function stack() {
|
||||
|
||||
/* This function provides the factor by which the stack of cointainers need to be multiplied to aquire the final zoom. */
|
||||
|
||||
var fullStack = {
|
||||
x: 1,
|
||||
y: 1
|
||||
}
|
||||
|
||||
if (this.parentZoom !== undefined) {
|
||||
|
||||
fullStack = this.parentZoom.stack();
|
||||
|
||||
}
|
||||
|
||||
fullStack.x = fullStack.x + fullStack.x * this.levelX * this.incrementX;
|
||||
fullStack.y = fullStack.y + fullStack.y * this.levelY * this.incrementY;
|
||||
|
||||
return fullStack;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
<script type="text/javascript" src="Container.js"></script>
|
||||
<script type="text/javascript" src="TimeMachine.js"></script>
|
||||
<script type="text/javascript" src="FloatingObject.js"></script>
|
||||
<script type="text/javascript" src="Balls.js"></script>
|
||||
<script type="text/javascript" src="Candle.js"></script>
|
||||
<script type="text/javascript" src="VolumeBar.js"></script>
|
||||
<script type="text/javascript" src="Order.js"></script>
|
||||
@@ -46,7 +45,6 @@
|
||||
<script type="text/javascript" src="ChartGrid.js"></script>
|
||||
<script type="text/javascript" src="TradesCursor.js"></script>
|
||||
<script type="text/javascript" src="Animation.js"></script>
|
||||
<script type="text/javascript" src="Zoom.js"></script>
|
||||
<script type="text/javascript" src="Displace.js"></script>
|
||||
<script type="text/javascript" src="TimeLineCoordinateSystem.js"></script>
|
||||
<script type="text/javascript" src="Utilities.js"></script>
|
||||
|
||||
Reference in new issue
Block a user