Cleaning User Position Concept

This commit is contained in:
Luis Fernando Molina committed 2020-01-30 23:33:33 +01:00
1 parent 1e4238ea3c
commit d109ef8a98
3 files changed
+9 -48

No files matched your search

+9 -4
View File
@@ -191,10 +191,15 @@ function newTimeMachine () {
thisObject.timeScale.initialize(timeMachineCoordinateSystem, thisObject.container)
function timeScaleValueChanged (event) {
thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale
recalculateCoordinateSystem()
if (event.isUserAction === true) {
// moveToUserPosition(thisObject.container, previousCoordinateSystem, timeMachineCoordinateSystem, false, true, event.mousePosition, true)
let currentDate = getDateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem)
let currentRate = getRateFromPoint(event.mousePosition, thisObject.container, timeMachineCoordinateSystem)
thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale
recalculateCoordinateSystem()
moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, false, true, event.mousePosition)
} else {
thisObject.container.frame.width = TIME_MACHINE_WIDTH + TIME_MACHINE_WIDTH * event.scale
recalculateCoordinateSystem()
}
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
}
@@ -219,7 +224,7 @@ function newTimeMachine () {
thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale
recalculateCoordinateSystem()
moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, true, false, event.mousePosition, true)
moveToUserPosition(thisObject.container, currentDate, currentRate, timeMachineCoordinateSystem, true, false, event.mousePosition)
} else {
thisObject.container.frame.height = TIME_MACHINE_HEIGHT + TIME_MACHINE_HEIGHT * event.scale
recalculateCoordinateSystem()
-3
View File
@@ -228,7 +228,6 @@ function newTimelineChart () {
function timeFrameScaleMouseOver (event) {
thisObject.container.eventHandler.raiseEvent('onChildrenMouseOver', event)
saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event)
}
}
@@ -260,8 +259,6 @@ function newTimelineChart () {
mouse.position.x = event.x
mouse.position.y = event.y
saveUserPosition(thisObject.container, timeMachineCoordinateSystem, event)
}
function onMouseNotOver (event) {
-41
View File
@@ -147,47 +147,6 @@ function getMilisecondsFromPoint (point, container, coordinateSystem) {
return point.x
}
function saveUserPosition (container, coordinateSystem, position) {
if (position === undefined) {
position = {
x: (canvas.chartSpace.viewport.visibleArea.bottomRight.x - canvas.chartSpace.viewport.visibleArea.topLeft.x) / 2,
y: (canvas.chartSpace.viewport.visibleArea.bottomRight.y - canvas.chartSpace.viewport.visibleArea.topLeft.y) / 2
}
}
let userPosition = {
date: getDateFromPoint(position, container, coordinateSystem),
rate: getRateFromPoint(position, container, coordinateSystem),
market: DEFAULT_MARKET,
zoom: canvas.chartSpace.viewport.zoomTargetLevel
}
window.localStorage.setItem('userPosition', JSON.stringify(userPosition))
}
function getUserPosition (coordinateSystem) {
let savedPosition = window.localStorage.getItem('userPosition')
let userPosition
if (savedPosition === null) {
userPosition = {
date: (new Date()).toString(),
rate: coordinateSystem.max.y / 2,
market: DEFAULT_MARKET,
zoom: INITIAL_ZOOM_LEVEL
}
} else {
userPosition = JSON.parse(savedPosition)
}
userPosition.point = {
x: (new Date(userPosition.date)).valueOf(),
y: userPosition.rate
}
return userPosition
}
function moveToUserPosition (container, currentDate, currentRate, coordinateSystem, ignoreX, ignoreY, mousePosition) {
let targetPoint = {
x: currentDate.valueOf(),