Move to user position
This commit is contained in:
1 parent
a6e22aaf9c
commit
f3ccf2f186
4 files changed
+332
-312
No files matched your search
+16
-5
@@ -75,7 +75,7 @@ function saveUserPosition (container, timeLineCoordinateSystem) {
|
||||
window.localStorage.setItem('userPosition', JSON.stringify(userPosition))
|
||||
}
|
||||
|
||||
function moveToUserPosition (container, timeLineCoordinateSystem) {
|
||||
function getUserPosition () {
|
||||
let savedPosition = window.localStorage.getItem('userPosition')
|
||||
let userPosition
|
||||
|
||||
@@ -90,11 +90,17 @@ function moveToUserPosition (container, timeLineCoordinateSystem) {
|
||||
userPosition = JSON.parse(savedPosition)
|
||||
}
|
||||
|
||||
let centerPoint = {
|
||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2,
|
||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2
|
||||
userPosition.point = {
|
||||
x: (new Date(userPosition.date)).valueOf(),
|
||||
y: userPosition.rate
|
||||
}
|
||||
|
||||
return userPosition
|
||||
}
|
||||
|
||||
function moveToUserPosition (container, timeLineCoordinateSystem) {
|
||||
let userPosition = getUserPosition()
|
||||
|
||||
viewPort.newZoomLevel(userPosition.zoom)
|
||||
INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom)
|
||||
INITIAL_DATE = new Date(userPosition.date)
|
||||
@@ -104,11 +110,16 @@ function moveToUserPosition (container, timeLineCoordinateSystem) {
|
||||
y: userPosition.rate
|
||||
}
|
||||
|
||||
/* Put this point in the coordinate system of the viewPort */
|
||||
/* Put this po int in the coordinate system of the viewPort */
|
||||
|
||||
targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint)
|
||||
targetPoint = transformThisPoint(targetPoint, container)
|
||||
|
||||
let centerPoint = {
|
||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2,
|
||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2
|
||||
}
|
||||
|
||||
/* Lets calculate the displace vector, from the point we want at the center, to the current center. */
|
||||
|
||||
let displaceVector = {
|
||||
|
||||
Reference in new issue
Block a user