---
metadata:
  - name: generator
    content: Diplodoc Platform v5.70.0
alternate:
  - https://divkit.tech/docs/en/concepts/extensions/gesture.md
  - https://divkit.tech/docs/ru/concepts/extensions/gesture.md
  - href: https://divkit.tech/docs/en/concepts/extensions/gesture.md
    type: text/markdown
    title: Markdown version
  - href: https://divkit.tech/docs/en/llms.txt?revision=r22102947
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://divkit.tech/docs/en/llms.txt?revision=r22102947

# Swipe gestures

The `gesture` extension runs [actions](https://divkit.tech/docs/en/concepts/divs/2/div-action.md) when the user swipes up, down, left, or right over the element.

{% cut "Example" %}

```json translate=no
{
  "type": "text",
  "text": "Last swipe: @{last_swipe}",
  "extensions": [
    {
      "id": "gesture",
      "params": {
        "swipe_left": [
          {
            "log_id": "swipe_left",
            "typed": {
              "type": "set_variable",
              "variable_name": "last_swipe",
              "value": {
                "type": "string",
                "value": "left"
              }
            }
          }
        ],
        "swipe_right": [
          {
            "log_id": "swipe_right",
            "typed": {
              "type": "set_variable",
              "variable_name": "last_swipe",
              "value": {
                "type": "string",
                "value": "right"
              }
            }
          }
        ]
      }
    }
  ]
}
```

In this example, a swipe to the left or to the right writes the direction to the `last_swipe` string variable.

{% endcut %}

## Parameters {#params}

#|
||
**Parameters**
|
**Description**
||

||
`id`
|
Extension ID.
||

||
`swipe_up`
|
Array of [actions](https://divkit.tech/docs/en/concepts/divs/2/div-action.md) that run on a swipe up. Optional parameter.
||

||
`swipe_down`
|
Array of actions that run on a swipe down. Optional parameter.
||

||
`swipe_left`
|
Array of actions that run on a swipe to the left. Optional parameter.
||

||
`swipe_right`
|
Array of actions that run on a swipe to the right. Optional parameter.
||
|#

Specify at least one of the parameters.

## Connection {#connect}

{% list tabs %}

- Android

  build.gradle

  ```groovy translate=no
  dependencies {
      implementation "com.yandex.div:div-gesture:${versions.divkit}"
  }
  ```

  In the code:

  ```kotlin translate=no
  val gestureExtensionHandler = DivGestureExtensionHandler(
      parsingErrorLoggerFactory = object : ParsingErrorLoggerFactory {
          override fun create(key: String) = ParsingErrorLogger.LOG
      }
  )
  val divConfiguration = DivConfiguration.Builder(imageLoader)
      .extension(gestureExtensionHandler)
      .build()
  ```

  `ParsingErrorLoggerFactory` creates the logger that receives the errors of parsing the actions from the parameter named `key`.

- iOS

  ```swift translate=no
  DivKitComponents(
    ...
    extensionHandlers: [
      GestureExtensionHandler()
    ]
  )
  ```

- Web

  ```js translate=no
  import { Gesture } from '@divkitframework/divkit/client';

  const map = new Map();

  map.set('gesture', Gesture);

  render({
      id: 'test',
      target: element,
      json: {},
      extensions: map
  });
  ```

{% endlist %}

<!-- source: en/_includes/index/troubleshooting.md -->
## Learn more {#troubleshooting}

You can discuss topics of interest in the DivKit user community in Telegram: [https://t.me/divkit_community_en](https://t.me/divkit_community_en).



[DivKit Repository](https://github.com/divkit/divkit)
<!-- endsource: en/_includes/index/troubleshooting.md -->
