Skip to content

Commit 133c575

Browse files
author
Bobby Jap
committed
Added one type of fix to the other two methods.
1 parent 583a088 commit 133c575

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/main/java/io/appium/java_client/AppiumDriver.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,18 @@ public void pinch(WebElement el) {
424424
*/
425425
public void pinch(int x, int y) {
426426
MultiTouchAction multiTouch = new MultiTouchAction(this);
427+
428+
int scrHeight = manage().window().getSize().getHeight();
429+
int yOffset = 100;
430+
431+
if (y - 100 < 0) {
432+
yOffset = y;
433+
} else if (y + 100 > scrHeight) {
434+
yOffset = scrHeight - y;
435+
}
427436

428-
TouchAction action0 = new TouchAction(this).press(x, y-100).moveTo(x, y).release();
429-
TouchAction action1 = new TouchAction(this).press(x, y+100).moveTo(x, y).release();
437+
TouchAction action0 = new TouchAction(this).press(x, y - yOffset).moveTo(x, y).release();
438+
TouchAction action1 = new TouchAction(this).press(x, y + yOffset).moveTo(x, y).release();
430439

431440
multiTouch.add(action0).add(action1);
432441

@@ -472,9 +481,18 @@ public void zoom(WebElement el) {
472481
*/
473482
public void zoom(int x, int y) {
474483
MultiTouchAction multiTouch = new MultiTouchAction(this);
484+
485+
int scrHeight = manage().window().getSize().getHeight();
486+
int yOffset = 100;
487+
488+
if (y - 100 < 0) {
489+
yOffset = y;
490+
} else if (y + 100 > scrHeight) {
491+
yOffset = scrHeight - y;
492+
}
475493

476-
TouchAction action0 = new TouchAction(this).press(x, y).moveTo(x, y-100).release();
477-
TouchAction action1 = new TouchAction(this).press(x, y).moveTo(x, y+100).release();
494+
TouchAction action0 = new TouchAction(this).press(x, y).moveTo(x, y - yOffset).release();
495+
TouchAction action1 = new TouchAction(this).press(x, y).moveTo(x, y + yOffset).release();
478496

479497
multiTouch.add(action0).add(action1);
480498

0 commit comments

Comments
 (0)