[Mobile, Gestures] Pinch

Moved MCTPinch directive into
plot-reborn. Now emits on pinch action
the event to the controller. Edited plot.html
to clean up and edited mct-plot.html to
include mct-pinch. DrawLoader adjusted to
allow  and prevent error.
This commit is contained in:
Shivam Dave
2015-08-17 12:51:33 -07:00
parent 17e2da2d2c
commit 5c3fe78bd5
7 changed files with 18 additions and 25 deletions

View File

@ -153,6 +153,10 @@ define(
}
};
}
function onPinchAction(event) {
console.log("TEST");
}
function followDataIfLive() {
if (isLive) {
@ -163,6 +167,7 @@ define(
$scope.$on('series:data:add', followDataIfLive);
$scope.$on('user:viewport:change:end', onUserViewportChangeEnd);
$scope.$on('user:viewport:change:start', onUserViewportChangeStart);
$scope.$on('mct:pinch:action', onPinchAction);
$scope.$watch('domainObject', linkDomainObject);

View File

@ -0,0 +1,81 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
[],
function () {
"use strict";
function MCTPinch($log, agentService) {
function link($scope, element, attrs) {
var posPrev,
evePrev;
// Returns position of touch event
function trackPosition(event) {
return [event.clientX, event.clientY];
}
function pinchAction(event) {
if (event.changedTouches.length === 2) {
var touchPosition = [trackPosition(event.changedTouches[0]),
trackPosition(event.changedTouches[1])],
touchPositionPrev = posPrev || touchPosition,
eventPrev = evePrev || event;
$scope.$emit('mct:pinch:action', event);
// Set current position to be previous position
// for next touch action
posPrev = touchPosition;
// Set current event to be previous event
// for next touch action
evePrev = event;
// Stops other gestures/button clicks from being active
event.preventDefault();
}
}
if (agentService.isMobile(navigator.userAgent)) {
element.on('touchstart', pinchAction);
element.on('touchmove', pinchAction);
element.on('touchend', pinchAction);
}
// Stop checking for resize when scope is destroyed
// $scope.$on("$destroy", destroyEverythingNow);
}
return {
restrict: "A",
// Link with the provided function
link: link
};
}
return MCTPinch;
}
);

View File

@ -5,7 +5,7 @@ define(
'./DrawWebGL',
'./Draw2D'
],
function (DrawWebGL, Draw2D) {
function ($log, DrawWebGL, Draw2D) {
var CHARTS = [
DrawWebGL,