Skip to content

Commit

Permalink
make sure ios native swipe commands aren't run on webview elements (fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed May 2, 2014
1 parent e23f58b commit 8272680
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/devices/ios/ios-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,9 @@ iOSController.fakeFlick = function (xSpeed, ySpeed, swipe, cb) {
};

iOSController.fakeFlickElement = function (elementId, xoffset, yoffset, speed, cb) {
if (this.isWebContext()) {
return cb(new NotYetImplementedError(), null);
}
var command = ["au.getElement('", elementId, "').touchFlick(", xoffset, ",",
yoffset, ",", speed, ")"].join('');
this.proxyWithMinTime(command, FLICK_MS, cb);
Expand All @@ -1105,6 +1108,9 @@ iOSController.fakeFlickElement = function (elementId, xoffset, yoffset, speed, c
iOSController.drag = function (startX, startY, endX, endY, duration, touchCount, elId, destElId, cb) {
var command;
if (elId) {
if (this.isWebContext()) {
return cb(new NotYetImplementedError(), null);
}
command = ["au.getElement('", elId, "').drag(", startX, ',', startY, ',',
endX, ',', endY, ',', duration, ',', touchCount, ")"].join('');
} else {
Expand All @@ -1128,6 +1134,9 @@ iOSController.rotate = function (x, y, radius, rotation, duration, touchCount, e
var location = {'x' : x, 'y' : y};
var options = {'duration' : duration, 'radius' : radius, 'rotation' : rotation, 'touchCount' : touchCount};
if (elId) {
if (this.isWebContext()) {
return cb(new NotYetImplementedError(), null);
}
command = "au.getElement('" + elId + "').rotateWithOptions(" + JSON.stringify(location) +
"," + JSON.stringify(options) + ")";
this.proxy(command, cb);
Expand Down Expand Up @@ -1158,6 +1167,9 @@ iOSController.pinchOpen = function (startX, startY, endX, endY, duration,
var fromPointObject = {'x' : startX, 'y' : startY};
var toPointObject = {'x' : endX, 'y' : endY};
if (elId) {
if (this.isWebContext()) {
return cb(new NotYetImplementedError(), null);
}
command = ["au.getElement('", elId, "').pinchOpenFromToForDuration(",
JSON.stringify(fromPointObject), ",", JSON.stringify(toPointObject), ",",
duration + ")"].join('');
Expand All @@ -1172,6 +1184,9 @@ iOSController.flick = function (startX, startY, endX, endY, touchCount, elId,
cb) {
var command;
if (elId) {
if (this.isWebContext()) {
return cb(new NotYetImplementedError(), null);
}
command = ["au.getElement('", elId, "').flick(", startX, ',', startY, ',',
endX, ',', endY, ',', touchCount, ")"].join('');
} else {
Expand All @@ -1182,6 +1197,9 @@ iOSController.flick = function (startX, startY, endX, endY, touchCount, elId,
};

iOSController.scrollTo = function (elementId, text, direction, cb) {
if (this.isWebContext()) {
return cb(new NotYetImplementedError(), null);
}
// we ignore text for iOS, as the element is the one being scrolled too
var command = ["au.getElement('", elementId, "').scrollToVisible()"].join('');
this.proxy(command, cb);
Expand All @@ -1192,6 +1210,9 @@ iOSController.scroll = function (elementId, direction, cb) {
// By default, scroll the first scrollview.
var command = "au.scrollFirstView('" + direction + "')";
if (elementId) {
if (this.isWebContext()) {
return cb(new NotYetImplementedError(), null);
}
// if elementId is defined, call scrollLeft, scrollRight, scrollUp, and scrollDown on the element.
command = ["au.getElement('", elementId, "').scroll", direction, "()"].join('');
}
Expand Down

0 comments on commit 8272680

Please sign in to comment.