/** * Check to see if the touch has moved off of the element. * * <p>NOTE that in iOS the elasticScroll may make the touch/move cancel more difficult. * * @param event */ private void onTouchMove(Event event) { if (!this.touchMoved) { Touch move = null; for (int i = 0; i < event.getChangedTouches().length(); i++) { if (event.getChangedTouches().get(i).getIdentifier() == this.touchId) { move = event.getChangedTouches().get(i); } } // Check to see if we moved off of the original element // Use Page coordinates since we compare with widget's absolute // coordinates if (move != null) { int yCord = move.getPageY(); int xCord = move.getPageX(); // is y above element boolean yTop = this.getAbsoluteTop() > yCord; boolean yBottom = (this.getAbsoluteTop() + this.getOffsetHeight()) < yCord; // y below // is x to the left of element boolean xLeft = this.getAbsoluteLeft() > xCord; boolean xRight = (this.getAbsoluteLeft() + this.getOffsetWidth()) < xCord; // x to the right if (yTop || yBottom || xLeft || xRight) { this.touchMoved = true; onHoldPressOffStyle(); // Go back to normal style } } } }
public MockTouchMoveEvent(int id1, int x1, int y1, int id2, int x2, int y2) { this(id1, x1, y1); final Touch touch1 = mock(Touch.class); when(touches.get(1)).thenReturn(touch1); when(touch1.getIdentifier()).thenReturn(id2); when(touch1.getPageX()).thenReturn(x2); when(touch1.getPageY()).thenReturn(y2); }
public MockTouchMoveEvent(int id, int x, int y) { touches = mock(JsArray.class); touch = mock(Touch.class); when(touches.length()).thenReturn(1); when(touches.get(0)).thenReturn(touch); when(touch.getIdentifier()).thenReturn(id); when(touch.getPageX()).thenReturn(x); when(touch.getPageY()).thenReturn(y); }