mirror of
https://github.com/nasa/openmct.git
synced 2025-06-23 01:18:57 +00:00
[Mobile] Gesture
Zooms in at 0.01 amount (like last commit) however the pinch's midpoint is the center point at which the zoom focuses on.
This commit is contained in:
@ -277,25 +277,41 @@ define(
|
|||||||
Math.pow(coordOne.clientY - coordTwo.clientY, 2));
|
Math.pow(coordOne.clientY - coordTwo.clientY, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateViewport(touchPostion, ratio) {
|
function setDR(midpoint) {
|
||||||
var tl, br;
|
return {
|
||||||
|
tl: {
|
||||||
|
domain: Math.abs(midpoint.domain - ($scope.viewport.topLeft.domain)),
|
||||||
|
range: Math.abs(midpoint.range - ($scope.viewport.topLeft.range))
|
||||||
|
},
|
||||||
|
|
||||||
|
br: {
|
||||||
|
domain: Math.abs(($scope.viewport.bottomRight.domain) - midpoint.domain),
|
||||||
|
range: Math.abs(($scope.viewport.bottomRight.range) - midpoint.range)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateViewport(midpoint, touchPosition, ratio) {
|
||||||
|
var tl,
|
||||||
|
br,
|
||||||
|
drSet = setDR(midpoint);
|
||||||
if (ratio < 1) {
|
if (ratio < 1) {
|
||||||
tl = {
|
tl = {
|
||||||
domain: 0.01,
|
domain: 0.01 * drSet.tl.domain,
|
||||||
range: 0.01
|
range: 0.01 * drSet.tl.range
|
||||||
};
|
};
|
||||||
br = {
|
br = {
|
||||||
domain: 0.01,
|
domain: 0.01 * drSet.br.domain,
|
||||||
range: 0.01
|
range: 0.01 * drSet.br.range
|
||||||
};
|
};
|
||||||
} else if (ratio > 1) {
|
} else if (ratio > 1) {
|
||||||
tl = {
|
tl = {
|
||||||
domain: - 0.01,
|
domain: - 0.01 * drSet.tl.domain,
|
||||||
range: - 0.01
|
range: - 0.01 * drSet.tl.range
|
||||||
};
|
};
|
||||||
br = {
|
br = {
|
||||||
domain: - 0.01,
|
domain: - 0.01 * drSet.br.domain,
|
||||||
range: - 0.01
|
range: - 0.01 * drSet.br.range
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +336,7 @@ define(
|
|||||||
newTouchPosition = [trackTouchPosition(touches[0], bounds).positionAsPlotPoint,
|
newTouchPosition = [trackTouchPosition(touches[0], bounds).positionAsPlotPoint,
|
||||||
trackTouchPosition(touches[1], bounds).positionAsPlotPoint],
|
trackTouchPosition(touches[1], bounds).positionAsPlotPoint],
|
||||||
distanceRatio = firstTouchDistance / distance,
|
distanceRatio = firstTouchDistance / distance,
|
||||||
newViewport = calculateViewport(newTouchPosition, distanceRatio);
|
newViewport = calculateViewport(newMidpointPosition, newTouchPosition, distanceRatio);
|
||||||
|
|
||||||
console.log(newViewport);
|
console.log(newViewport);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user