[Time Conductor] Handle middle drag

WTD-1515
This commit is contained in:
Victor Woeltjen
2015-09-02 17:25:41 -07:00
parent 57a947eaef
commit 9d6b70f433

View File

@ -106,7 +106,7 @@ define(
function startMiddleDrag() { function startMiddleDrag() {
initialDragValue = [ initialDragValue = [
$scope.ngModel.inner[0], $scope.ngModel.inner[0],
$scope.ngModel.inner[0] $scope.ngModel.inner[1]
]; ];
} }
@ -142,24 +142,27 @@ define(
function middleDrag(pixels) { function middleDrag(pixels) {
var delta = toMillis(pixels), var delta = toMillis(pixels),
index = delta < 0 ? 0 : 1, index = delta < 0 ? 0 : 1,
opposite = (index === 0) ? 1 : 0, opposite = Math.abs(1 - index);
span = initialDragValue[opposite] - initialDragValue[index];
// Adjust the position of the edge in the direction of drag
$scope.ngModel.inner[index] = clamp( $scope.ngModel.inner[index] = clamp(
initialDragValue[index] + delta, initialDragValue[index] + delta,
$scope.ngModel.outer[0], $scope.ngModel.outer[0],
$scope.ngModel.outer[1] $scope.ngModel.outer[1]
); );
$scope.ngModel.inner[opposite] = // Adjust opposite knob to maintain span
$scope.ngModel.inner[index] + span; $scope.ngModel.inner[opposite] = $scope.ngModel.inner[index] +
initialDragValue[opposite] - initialDragValue[index];
updateFromParameters($scope.ngModel);
} }
$scope.startLeftDrag = startLeftDrag; $scope.startLeftDrag = startLeftDrag;
$scope.startRightDrag = startRightDrag; $scope.startRightDrag = startRightDrag;
//$scope.startMiddleDrag = startMiddleDrag; $scope.startMiddleDrag = startMiddleDrag;
$scope.leftDrag = leftDrag; $scope.leftDrag = leftDrag;
$scope.rightDrag = rightDrag; $scope.rightDrag = rightDrag;
//$scope.middleDrag = middleDrag; $scope.middleDrag = middleDrag;
$scope.state = false; $scope.state = false;
$scope.ticks = []; $scope.ticks = [];