mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 22:50:49 +00:00
[Mobile] Comments
Added comments to the MCTPinch file.
This commit is contained in:
parent
f9be00a70f
commit
052a359738
@ -151,7 +151,8 @@ define(
|
|||||||
dragStart = undefined;
|
dragStart = undefined;
|
||||||
$scope.$emit('user:viewport:change:end', $scope.viewport);
|
$scope.$emit('user:viewport:change:end', $scope.viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
function trackTouchPosition(touchPosition, bounds) {
|
function trackTouchPosition(touchPosition, bounds) {
|
||||||
var positionOverElement,
|
var positionOverElement,
|
||||||
positionAsPlotPoint,
|
positionAsPlotPoint,
|
||||||
@ -273,12 +274,17 @@ define(
|
|||||||
updateAxesForCurrentViewport();
|
updateAxesForCurrentViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Updates viewport based on touch location and current event bounds
|
||||||
function updatePan(touch, bounds) {
|
function updatePan(touch, bounds) {
|
||||||
|
|
||||||
|
// Sets the panPosition plot point (relative to chart)
|
||||||
|
// and calculates domain/range by subtracting first touch's
|
||||||
|
// plot point and current touch's plot point
|
||||||
var panPosition = trackTouchPosition(touch, bounds).positionAsPlotPoint,
|
var panPosition = trackTouchPosition(touch, bounds).positionAsPlotPoint,
|
||||||
dDomain = firstTouch.domain - panPosition.domain,
|
dDomain = firstTouch.domain - panPosition.domain,
|
||||||
dRange = firstTouch.range - panPosition.range;
|
dRange = firstTouch.range - panPosition.range;
|
||||||
|
|
||||||
|
// Viewport is set to calculated delta domain/range
|
||||||
$scope.viewport = {
|
$scope.viewport = {
|
||||||
topLeft: {
|
topLeft: {
|
||||||
domain: (($scope.viewport.topLeft.domain) + dDomain),
|
domain: (($scope.viewport.topLeft.domain) + dDomain),
|
||||||
@ -291,20 +297,26 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Starts the pan by emitting that viewport will be changed
|
||||||
|
// also sets the first touch variable
|
||||||
function startPan(touch, bounds) {
|
function startPan(touch, bounds) {
|
||||||
$scope.$emit('user:viewport:change:start');
|
$scope.$emit('user:viewport:change:start');
|
||||||
firstTouch = trackTouchPosition(touch, bounds).positionAsPlotPoint;
|
firstTouch = trackTouchPosition(touch, bounds).positionAsPlotPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//Receives the emit of single touch pan start
|
||||||
function onPanStart(event, touch) {
|
function onPanStart(event, touch) {
|
||||||
startPan(touch.touch, touch.bounds);
|
startPan(touch.touch, touch.bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Receives the emit of single touch pan change
|
||||||
function onPanChange(event, touch) {
|
function onPanChange(event, touch) {
|
||||||
updatePan(touch.touch, touch.bounds);
|
updatePan(touch.touch, touch.bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets the dimensions of the midpoint's domain and range distance to the
|
||||||
|
// top left and bottom right corners of the viewport. Used to zoom relative to
|
||||||
|
// midpoint pinch gestures 2 touches.
|
||||||
function setDimensions(midpoint) {
|
function setDimensions(midpoint) {
|
||||||
return {
|
return {
|
||||||
tl: {
|
tl: {
|
||||||
@ -318,13 +330,21 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculates the viewport for a zoom gesture
|
||||||
function calculateViewport(midpoint, ratio) {
|
function calculateViewport(midpoint, ratio) {
|
||||||
|
|
||||||
|
// Uses the distance ratio passed in and the
|
||||||
|
// zoom amount (variable set at top) to find the
|
||||||
|
// amount of zoom per change in pinch gesture and
|
||||||
|
// whether it is zooming in or out
|
||||||
var zoomTL, zoomBR,
|
var zoomTL, zoomBR,
|
||||||
dimensions = setDimensions(midpoint),
|
dimensions = setDimensions(midpoint),
|
||||||
checkRatio = (ratio - 1) || 0,
|
checkRatio = (ratio - 1) || 0,
|
||||||
type = (-1 * (checkRatio / Math.abs(checkRatio))) || 1,
|
type = (-1 * (checkRatio / Math.abs(checkRatio))) || 1,
|
||||||
zoomAmt = type * ZOOM_AMT;
|
zoomAmt = type * ZOOM_AMT;
|
||||||
|
|
||||||
|
// Sets the domain/range difference to applied to the
|
||||||
|
// top left and bottom right plot points
|
||||||
zoomTL = {
|
zoomTL = {
|
||||||
domain: zoomAmt * dimensions.tl.domain,
|
domain: zoomAmt * dimensions.tl.domain,
|
||||||
range: zoomAmt * dimensions.tl.range
|
range: zoomAmt * dimensions.tl.range
|
||||||
@ -334,6 +354,8 @@ define(
|
|||||||
range: zoomAmt * dimensions.br.range
|
range: zoomAmt * dimensions.br.range
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Applies and returns the changed for zoom top left and bottom right
|
||||||
|
// plot points
|
||||||
return {
|
return {
|
||||||
topLeft: {
|
topLeft: {
|
||||||
domain: (($scope.viewport.topLeft.domain) + zoomTL.domain),
|
domain: (($scope.viewport.topLeft.domain) + zoomTL.domain),
|
||||||
@ -346,21 +368,28 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Updates the viewport based on the amount of zooming (pinching) user is doing
|
||||||
function updateZoom(midpoint, bounds, distance) {
|
function updateZoom(midpoint, bounds, distance) {
|
||||||
|
|
||||||
|
// Gets the current midpoint and distance ratio to be used to
|
||||||
|
// calculate new viewport
|
||||||
var midpointPosition = trackTouchPosition(midpoint, bounds).positionAsPlotPoint,
|
var midpointPosition = trackTouchPosition(midpoint, bounds).positionAsPlotPoint,
|
||||||
distanceRatio = ((prevTouchDistance || firstTouchDistance) / distance);
|
distanceRatio = ((prevTouchDistance || firstTouchDistance) / distance);
|
||||||
|
|
||||||
|
// Sets the new viewport
|
||||||
$scope.viewport = calculateViewport(midpointPosition, distanceRatio);
|
$scope.viewport = calculateViewport(midpointPosition, distanceRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Starts the zoom by emitting that viewport will be changed
|
||||||
|
// also sets the first touch variable (midpoint) if panning will happen
|
||||||
|
// and sets the distance between the first touches occurring
|
||||||
function startZoom(midpoint, bounds, touches, distance) {
|
function startZoom(midpoint, bounds, touches, distance) {
|
||||||
|
$scope.$emit('user:viewport:change:start');
|
||||||
firstTouchDistance = distance;
|
firstTouchDistance = distance;
|
||||||
firstTouch = trackTouchPosition(midpoint, bounds).positionAsPlotPoint;
|
firstTouch = trackTouchPosition(midpoint, bounds).positionAsPlotPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
function onPinchStart(event, touch) {
|
function onPinchStart(event, touch) {
|
||||||
$scope.$emit('user:viewport:change:start');
|
|
||||||
startZoom(touch.midpoint, touch.bounds, touch.touches, touch.distance);
|
startZoom(touch.midpoint, touch.bounds, touch.touches, touch.distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user