timeScale with its own physics

This commit is contained in:
Luis Fernando Molina committed 2020-01-10 09:17:17 +01:00
1 parent edb90b45e4
commit 09957fc96e
2 files changed
+74 -37

No files matched your search

+5 -36
View File
@@ -113,15 +113,16 @@ function newTimeMachine () {
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
function onMouseOver (event) {
mouse.position.x = event.x
mouse.position.y = event.y
if (thisObject.timeScale !== undefined) {
thisObject.timeScale.visible = true
thisObject.timeScale.onMouseOverSomeInnerContainer(event)
}
if (thisObject.rateScale !== undefined) {
thisObject.rateScale.visible = true
}
mouse.position.x = event.x
mouse.position.y = event.y
}
onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
@@ -150,7 +151,7 @@ function newTimeMachine () {
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
})
thisObject.timeScale.initialize()
thisObject.timeScale.initialize(timeLineCoordinateSystem, thisObject.container)
timeScaleMouseOverEventSuscriptionId = thisObject.timeScale.container.eventHandler.listenToEvent('onMouseOver', timeScaleMouseOver)
@@ -351,18 +352,6 @@ function newTimeMachine () {
upCorner = transformThisPoint(upCorner, thisObject.container)
bottonCorner = transformThisPoint(bottonCorner, thisObject.container)
/* Mouse Position Date Calculation */
if (thisObject.timeScale !== undefined) {
let timePoint = {
x: mouse.position.x,
y: 0
}
let mouseDate = getDateFromPoint(timePoint, thisObject.container, timeLineCoordinateSystem)
thisObject.timeScale.date = new Date(mouseDate)
}
/* Mouse Position Rate Calculation */
if (thisObject.rateScale !== undefined) {
let ratePoint = {
@@ -375,26 +364,6 @@ function newTimeMachine () {
thisObject.rateScale.rate = mouseRate
}
/* timeScale Positioning */
if (thisObject.timeScale !== undefined) {
timePoint = {
x: 0,
y: 0
}
timePoint = transformThisPoint(timePoint, thisObject.container.frame.container)
timePoint.x = mouse.position.x - thisObject.timeScale.container.frame.width / 2
timePoint = thisObject.container.fitFunction(timePoint)
/* Checking against the container limits. */
if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x }
if (timePoint.x + thisObject.timeScale.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.timeScale.container.frame.width }
if (timePoint.y < upCorner.y) { timePoint.y = upCorner.y }
if (timePoint.y + thisObject.timeScale.container.frame.height > bottonCorner.y) { timePoint.y = bottonCorner.y - thisObject.timeScale.container.frame.height }
thisObject.timeScale.container.frame.position.x = timePoint.x
thisObject.timeScale.container.frame.position.y = timePoint.y
}
/* rateScale Positioning */
if (thisObject.rateScale !== undefined) {
ratePoint = {
+69 -1
View File
@@ -8,6 +8,7 @@ function newTimeScale () {
fitFunction: undefined,
payload: undefined,
visible: true,
onMouseOverSomeInnerContainer: onMouseOverSomeInnerContainer,
physics: physics,
draw: draw,
getContainer: getContainer,
@@ -35,6 +36,15 @@ function newTimeScale () {
let onMouseOverEventSubscriptionId
let onMouseNotOverEventSubscriptionId
let timeLineCoordinateSystem
let limitingContainer
let mouse = {
position: {
x: 0,
y: 0
}
}
return thisObject
function finalize () {
@@ -46,9 +56,16 @@ function newTimeScale () {
thisObject.container = undefined
thisObject.fitFunction = undefined
thisObject.payload = undefined
timeLineCoordinateSystem = undefined
limitingContainer = undefined
mouse = undefined
}
function initialize () {
function initialize (pTimeLineCoordinateSystem, pLimitingContainer) {
timeLineCoordinateSystem = pTimeLineCoordinateSystem
limitingContainer = pLimitingContainer
onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
@@ -65,6 +82,15 @@ function newTimeScale () {
thisObject.container.eventHandler.raiseEvent('Lenght Percentage Changed', event)
}
function onMouseOverSomeInnerContainer (event) {
mouse = {
position: {
x: event.x,
y: event.y
}
}
}
function onMouseOver () {
thisObject.visible = true
isMouseOver = true
@@ -97,7 +123,49 @@ function newTimeScale () {
}
function physics () {
/* Container Limits */
let upCorner = {
x: 0,
y: 0
}
let bottonCorner = {
x: limitingContainer.frame.width,
y: limitingContainer.frame.height
}
upCorner = transformThisPoint(upCorner, limitingContainer)
bottonCorner = transformThisPoint(bottonCorner, limitingContainer)
/* Mouse Position Date Calculation */
let timePoint = {
x: mouse.position.x,
y: 0
}
let mouseDate = getDateFromPoint(timePoint, limitingContainer, timeLineCoordinateSystem)
thisObject.date = new Date(mouseDate)
/* timeScale Positioning */
timePoint = {
x: 0,
y: 0
}
timePoint = transformThisPoint(timePoint, limitingContainer.frame.container)
timePoint.x = mouse.position.x - thisObject.container.frame.width / 2
timePoint = limitingContainer.fitFunction(timePoint)
/* Checking against the container limits. */
if (timePoint.x < upCorner.x) { timePoint.x = upCorner.x }
if (timePoint.x + thisObject.container.frame.width > bottonCorner.x) { timePoint.x = bottonCorner.x - thisObject.container.frame.width }
if (timePoint.y < upCorner.y) { timePoint.y = upCorner.y }
if (timePoint.y + thisObject.container.frame.height > bottonCorner.y) { timePoint.y = bottonCorner.y - thisObject.container.frame.height }
thisObject.container.frame.position.x = timePoint.x
thisObject.container.frame.position.y = timePoint.y
}
function draw () {