Swipe by Coordinates
The Swipe by Coordinates action performs a swipe gesture between two specific points on the screen. Unlike the Swipe action, this method gives you precise control over where the gesture starts and ends.
When to Use
Use this action when you want to:
- Perform custom swipe gestures.
- Interact with drawing applications.
- Swipe inside maps.
- Navigate custom UI components.
- Perform gestures where direction-based swiping is insufficient.
Syntax
var task = suremdmjs.automate().swipeCoordinates(
"<Start X,Y>",
"<End X,Y>"
);
suremdmjs.automate().performAction(
task,
"onSuccess",
"onFailure"
);
Parameters
| Parameter | Required | Description |
|---|---|---|
| Start X,Y | Yes | Starting screen coordinate in "x,y" format. |
| End X,Y | Yes | Ending screen coordinate in "x,y" format. |
Parameter Details
Start X,Y
Specifies the location where the swipe begins.
Example:
300,1500
End X,Y
Specifies the location where the swipe ends.
Example:
300,500
Example
!#suremdmjs
performSwipe();
function performSwipe() {
var task = suremdmjs.automate().swipeCoordinates(
"300,1500",
"300,500"
);
suremdmjs.automate().performAction(
task,
"onSwipeCompleted",
"onFailure"
);
}
function onSwipeCompleted() {
suremdmjs.log("Swipe completed.");
}
function onFailure() {
suremdmjs.log("Swipe failed.");
}
How This Example Works
- Defines the swipe start position.
- Defines the swipe end position.
- Performs the gesture between both coordinates.
- Executes the success callback.
Expected Result
A swipe gesture is performed between the specified screen coordinates.
note
Coordinates are measured in screen pixels and may differ across devices with different screen sizes or display resolutions.