# Swipe Functions for Native Mobile Applications

**URL:** <https://discuss.appium.io/t/swipe-functions-for-native-mobile-applications/44950>\
**Category:** Tutorials/Documentation\
**Created:** [October 26, 2024, 2:31pm UTC](https://discuss.appium.io/t/swipe-functions-for-native-mobile-applications/44950 "2024-10-26T14:31:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harshada](https://discuss.appium.io/user_avatar/discuss.appium.io/harshada/32/12409_2.png) [@Harshada](https://discuss.appium.io/u/Harshada)\
**Post date:** [October 26, 2024, 2:31pm UTC](https://discuss.appium.io/t/swipe-functions-for-native-mobile-applications/44950/1 "2024-10-26T14:31:51Z")

</div>

**Swipe Right** :

```auto
export async function swipeRight() {
    if (driver.isAndroid) {
        await $('android=new UiScrollable(new UiSelector()).setAsHorizontalList().scrollForward()');
    } else {
        const screenSize = await driver.getWindowRect();
        const startX = screenSize.width * 0.9;
        const endX = screenSize.width * 0.1;
        const y = screenSize.height / 2;

        await driver.execute('mobile: swipe', {
            direction: 'left',
            element: null,
            startX: startX,
            startY: y,
            endX: endX,
            endY: y,
            duration: 1000,
        });
    }
}

```

- For Android devices, this function uses the `UiScrollable` class to scroll forward in a horizontal list. On iOS, it performs a swipe gesture from the right side of the screen to the left, allowing users to navigate to the previous content seamlessly.

**Swipe Left** :

```auto
export async function swipeLeft() {
    if (driver.isAndroid) {
        await $('android=new UiScrollable(new UiSelector()).setAsHorizontalList().scrollBackward()');
    } else {
        const screenSize = await driver.getWindowRect();
        const startX = screenSize.width * 0.9;
        const endX = screenSize.width * 0.1;
        const y = screenSize.height / 2;

        await driver.execute('mobile: swipe', {
            direction: 'right',
            element: null,
            startX: startX,
            startY: y,
            endX: endX,
            endY: y,
            duration: 1000,
        });
    }
}

```

- This function for Android uses `UiScrollable` to scroll backward in a horizontal list. On iOS, it performs a swipe gesture from the left side of the screen to the right, allowing users to navigate to the next content smoothly.
