diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 89c59aa18..6435b4270 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -245,7 +245,7 @@ function newTimeMachine () { let container if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { - container = thisObject.rateScale.getContainer(point) + container = thisObject.rateScale.getContainer(point, purpose) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container @@ -254,7 +254,7 @@ function newTimeMachine () { } if (thisObject.timeScale !== undefined && thisObject.timeScale.isVisible === true) { - container = thisObject.timeScale.getContainer(point) + container = thisObject.timeScale.getContainer(point, purpose) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container @@ -263,7 +263,7 @@ function newTimeMachine () { } if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { - container = thisObject.timeFrameScale.getContainer(point) + container = thisObject.timeFrameScale.getContainer(point, purpose) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index 69e2d65ed..a7ce14665 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -293,7 +293,7 @@ function newTimelineChart () { let container if (thisObject.rateScale !== undefined && thisObject.rateScale.isVisible === true) { - container = thisObject.rateScale.getContainer(point) + container = thisObject.rateScale.getContainer(point, purpose) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container @@ -302,7 +302,7 @@ function newTimelineChart () { } if (thisObject.timeFrameScale !== undefined && thisObject.timeFrameScale.isVisible === true) { - container = thisObject.timeFrameScale.getContainer(point) + container = thisObject.timeFrameScale.getContainer(point, purpose) if (container !== undefined) { if (container.isForThisPurpose(purpose)) { return container diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 228dd2c5f..1c7290efd 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -39,6 +39,10 @@ function newRateScale () { thisObject.offset = DEFAULT_OFFSET + let draggeableContainer = newContainer() + draggeableContainer.initialize(MODULE_NAME + ' Draggeable') + draggeableContainer.isDraggeable = true + let visible = true let isMouseOver @@ -172,8 +176,12 @@ function newRateScale () { } } - function getContainer (point) { + function getContainer (point, purpose) { if (thisObject.container.frame.isThisPointHere(point, true) === true) { + if (purpose === GET_CONTAINER_PURPOSE.DRAGGING) { + return draggeableContainer + } + return thisObject.container } } @@ -239,6 +247,31 @@ function newRateScale () { offsetTimer-- readObjectState() positioningPhysics() + draggingPhysics() + } + + function draggingPhysics () { + if (draggeableContainer.frame.position.y === 0) { return } + + let dragVector = { + x: draggeableContainer.frame.position.x, + y: draggeableContainer.frame.position.y + } + + draggeableContainer.frame.position.x = 0 + draggeableContainer.frame.position.y = 0 + + let point = { + x: 0, + y: -dragVector.y + } + + let newMaxRate = getRateFromPointAtContainer(point, limitingContainer, coordinateSystem) + let yDifferenceMaxMin = coordinateSystem.max.y - coordinateSystem.min.y + + coordinateSystem.min.y = newMaxRate - yDifferenceMaxMin + coordinateSystem.max.y = newMaxRate + coordinateSystem.recalculateScale() } function positioningPhysics () {