diff --git a/ChartingSpace/EdgeEditor.js b/ChartingSpace/EdgeEditor.js index 78f327139..ccffbfc4c 100644 --- a/ChartingSpace/EdgeEditor.js +++ b/ChartingSpace/EdgeEditor.js @@ -163,7 +163,11 @@ function newEdgeEditor () { coordinateSystem.max.x = newMinDate.valueOf() + xDifferenceMaxMin coordinateSystem.min.y = newMaxRate - yDifferenceMaxMin coordinateSystem.max.y = newMaxRate - coordinateSystem.recalculateScale() + let event = { + type: 'center dragged', + dragVector: dragVector + } + coordinateSystem.recalculateScale(event) } } thisObject.container.parentContainer.eventHandler.raiseEvent('onMouseOver', mouse.position) @@ -188,7 +192,7 @@ function newEdgeEditor () { coordinateSystem.max.y = newMaxRate coordinateSystem.maxHeight = thisObject.container.parentContainer.frame.height let event = { - border: 'top', + type: 'top dragged', dragVector: dragVector } coordinateSystem.recalculateScale(event) @@ -221,7 +225,7 @@ function newEdgeEditor () { coordinateSystem.min.y = newMinRate coordinateSystem.maxHeight = thisObject.container.parentContainer.frame.height let event = { - border: 'bottom', + type: 'bottom dragged', dragVector: dragVector } coordinateSystem.recalculateScale(event) diff --git a/ChartingSpace/TimelineChart.js b/ChartingSpace/TimelineChart.js index 4444579bb..ce39cf53d 100644 --- a/ChartingSpace/TimelineChart.js +++ b/ChartingSpace/TimelineChart.js @@ -233,7 +233,7 @@ function newTimelineChart () { function onScaleChanged (event) { if (thisObject.rateScale !== undefined) { - thisObject.rateScale.onBorderChanged(event) + thisObject.rateScale.onUpstreamScaleChanged(event) } timelineChartCoordinateSystem.min.x = timeMachineCoordinateSystem.min.x timelineChartCoordinateSystem.max.x = timeMachineCoordinateSystem.max.x diff --git a/Scales/RateScale.js b/Scales/RateScale.js index c91043535..07b2396a7 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -10,7 +10,7 @@ function newRateScale () { maxValue: undefined, isVisible: true, layersOn: undefined, - onBorderChanged: onBorderChanged, + onUpstreamScaleChanged: onUpstreamScaleChanged, onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer, physics: physics, draw: draw, @@ -244,9 +244,25 @@ function newRateScale () { coordinateSystem.recalculateScale() } - function onBorderChanged (event) { + function onUpstreamScaleChanged (event) { if (event === undefined) { return } - if (event.border === 'top') { + if (event.type === 'center dragged') { + let point = { + x: event.dragVector.x, + y: -event.dragVector.y + } + let newMinDate = getDateFromPointAtContainer(point, rateCalculationsContainer, coordinateSystem) + let newMaxRate = getRateFromPointAtContainer(point, rateCalculationsContainer, coordinateSystem) + let xDifferenceMaxMin = coordinateSystem.max.x - coordinateSystem.min.x + let yDifferenceMaxMin = coordinateSystem.max.y - coordinateSystem.min.y + coordinateSystem.min.x = newMinDate.valueOf() + coordinateSystem.max.x = newMinDate.valueOf() + xDifferenceMaxMin + coordinateSystem.min.y = newMaxRate - yDifferenceMaxMin + coordinateSystem.max.y = newMaxRate + + coordinateSystem.recalculateScale() + } + if (event.type === 'top dragged') { let point = { x: event.dragVector.x, y: event.dragVector.y @@ -257,7 +273,7 @@ function newRateScale () { coordinateSystem.maxHeight = rateCalculationsContainer.frame.height coordinateSystem.recalculateScale() } - if (event.border === 'bottom') { + if (event.type === 'bottom dragged') { let point = { x: event.dragVector.x, y: event.dragVector.y + rateCalculationsContainer.frame.height