mirror of
https://github.com/nasa/openmct.git
synced 2025-05-13 14:03:21 +00:00
[Mobile} Pan/Pinch
Cleaned up the variables.
This commit is contained in:
parent
bdf3e4d8a3
commit
a45b09277e
@ -51,7 +51,7 @@
|
||||
{
|
||||
"key": "mctPinch",
|
||||
"implementation": "directives/MCTPinch.js",
|
||||
"depends": [ "$log", "agentService" ]
|
||||
"depends": [ "agentService" ]
|
||||
}
|
||||
],
|
||||
"controllers": [
|
||||
|
@ -26,10 +26,9 @@ define(
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function MCTPinch($log, agentService) {
|
||||
|
||||
function link($scope, element, attrs) {
|
||||
function MCTPinch(agentService) {
|
||||
|
||||
function link($scope, element) {
|
||||
// Returns position of touch event
|
||||
function trackPosition(event) {
|
||||
return {
|
||||
@ -55,23 +54,25 @@ define(
|
||||
// On touch start the 'touch' is tracked and
|
||||
// the event is emitted through scope
|
||||
function touchStart(event) {
|
||||
var touchPosition;
|
||||
|
||||
if (event.changedTouches.length === 2 ||
|
||||
event.touches.length === 2) {
|
||||
var touchPositions = [trackPosition(event.touches[0]),
|
||||
touchPosition = [trackPosition(event.touches[0]),
|
||||
trackPosition(event.touches[1])];
|
||||
|
||||
$scope.$emit('mct:pinch:start', {
|
||||
touches: touchPositions,
|
||||
touches: touchPosition,
|
||||
bounds: event.target.getBoundingClientRect(),
|
||||
midpoint: calculateMidpoint(touchPositions[0], touchPositions[1]),
|
||||
distance: calculateDistance(touchPositions[0], touchPositions[1])
|
||||
midpoint: calculateMidpoint(touchPosition[0], touchPosition[1]),
|
||||
distance: calculateDistance(touchPosition[0], touchPosition[1])
|
||||
});
|
||||
|
||||
// Stops other gestures/button clicks from being active
|
||||
event.preventDefault();
|
||||
} else if (event.changedTouches.length === 1 ||
|
||||
event.touches.length === 1) {
|
||||
var touchPosition = trackPosition(event.touches[0]);
|
||||
touchPosition = trackPosition(event.touches[0]);
|
||||
|
||||
$scope.$emit('mct:pan:start', {
|
||||
touch: touchPosition,
|
||||
@ -86,21 +87,23 @@ define(
|
||||
// As the touch move occurs, the touches are tracked and
|
||||
// the event is emitted through scope
|
||||
function touchChange(event) {
|
||||
var touchPosition;
|
||||
|
||||
if (event.changedTouches.length === 2) {
|
||||
var touchPositions = [trackPosition(event.changedTouches[0]),
|
||||
touchPosition = [trackPosition(event.changedTouches[0]),
|
||||
trackPosition(event.changedTouches[1])];
|
||||
|
||||
$scope.$emit('mct:pinch:change', {
|
||||
touches: touchPositions,
|
||||
touches: touchPosition,
|
||||
bounds: event.target.getBoundingClientRect(),
|
||||
midpoint: calculateMidpoint(touchPositions[0], touchPositions[1]),
|
||||
distance: calculateDistance(touchPositions[0], touchPositions[1])
|
||||
midpoint: calculateMidpoint(touchPosition[0], touchPosition[1]),
|
||||
distance: calculateDistance(touchPosition[0], touchPosition[1])
|
||||
});
|
||||
|
||||
// Stops other gestures/button clicks from being active
|
||||
event.preventDefault();
|
||||
} else if (event.changedTouches.length === 1) {
|
||||
var touchPosition = trackPosition(event.changedTouches[0]);
|
||||
touchPosition = trackPosition(event.changedTouches[0]);
|
||||
|
||||
$scope.$emit('mct:pan:change', {
|
||||
touch: touchPosition,
|
||||
|
Loading…
x
Reference in New Issue
Block a user