Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,10 @@ public void pinch(WebElement el) {
Dimension dimensions = el.getSize();
Point upperLeft = el.getLocation();
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
int yOffset = center.getY() - upperLeft.getY();

TouchAction action0 = new TouchAction(this).press(el, center.getX(), center.getY() - 100).moveTo(el).release();
TouchAction action1 = new TouchAction(this).press(el, center.getX(), center.getY() + 100).moveTo(el).release();
TouchAction action0 = new TouchAction(this).press(el, center.getX(), center.getY() - yOffset).moveTo(el).release();
TouchAction action1 = new TouchAction(this).press(el, center.getX(), center.getY() + yOffset).moveTo(el).release();

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

Expand All @@ -423,9 +424,18 @@ public void pinch(WebElement el) {
*/
public void pinch(int x, int y) {
MultiTouchAction multiTouch = new MultiTouchAction(this);

int scrHeight = manage().window().getSize().getHeight();
int yOffset = 100;

if (y - 100 < 0) {
yOffset = y;
} else if (y + 100 > scrHeight) {
yOffset = scrHeight - y;
}

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

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

Expand All @@ -448,9 +458,10 @@ public void zoom(WebElement el) {
Dimension dimensions = el.getSize();
Point upperLeft = el.getLocation();
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
int yOffset = center.getY() - upperLeft.getY();

TouchAction action0 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() - 100).release();
TouchAction action1 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() + 100).release();
TouchAction action0 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() - yOffset).release();
TouchAction action1 = new TouchAction(this).press(el).moveTo(el, center.getX(), center.getY() + yOffset).release();

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

Expand All @@ -470,9 +481,18 @@ public void zoom(WebElement el) {
*/
public void zoom(int x, int y) {
MultiTouchAction multiTouch = new MultiTouchAction(this);

int scrHeight = manage().window().getSize().getHeight();
int yOffset = 100;

if (y - 100 < 0) {
yOffset = y;
} else if (y + 100 > scrHeight) {
yOffset = scrHeight - y;
}

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

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

Expand Down