{"id":25083161,"url":"https://github.com/glepur/react-native-swipe-gestures","last_synced_at":"2025-05-15T07:07:52.438Z","repository":{"id":39717210,"uuid":"76981597","full_name":"glepur/react-native-swipe-gestures","owner":"glepur","description":"4-directional swipe gestures for react-native","archived":false,"fork":false,"pushed_at":"2022-05-19T16:07:33.000Z","size":22,"stargazers_count":608,"open_issues_count":45,"forks_count":158,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T13:00:18.249Z","etag":null,"topics":["gesture","gestures","react-native","swipe","touch"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glepur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-20T18:28:59.000Z","updated_at":"2024-11-15T06:31:49.000Z","dependencies_parsed_at":"2022-07-20T13:32:24.256Z","dependency_job_id":null,"html_url":"https://github.com/glepur/react-native-swipe-gestures","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glepur%2Freact-native-swipe-gestures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glepur%2Freact-native-swipe-gestures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glepur%2Freact-native-swipe-gestures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glepur%2Freact-native-swipe-gestures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glepur","download_url":"https://codeload.github.com/glepur/react-native-swipe-gestures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292043,"owners_count":22046426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gesture","gestures","react-native","swipe","touch"],"created_at":"2025-02-07T06:17:58.428Z","updated_at":"2025-05-15T07:07:47.429Z","avatar_url":"https://github.com/glepur.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-swipe-gestures\n\nReact Native component for handling swipe gestures in up, down, left and right direction.\n\n## Installation\n\n`npm i -S react-native-swipe-gestures`\n\n## Usage\n\n```javascript\n'use strict';\n\nimport React, {Component} from 'react';\nimport {View, Text} from 'react-native';\nimport GestureRecognizer, {swipeDirections} from 'react-native-swipe-gestures';\n\nclass SomeComponent extends Component {\n\n  constructor(props) {\n    super(props);\n    this.state = {\n      myText: 'I\\'m ready to get swiped!',\n      gestureName: 'none',\n      backgroundColor: '#fff'\n    };\n  }\n\n  onSwipeUp(gestureState) {\n    this.setState({myText: 'You swiped up!'});\n  }\n\n  onSwipeDown(gestureState) {\n    this.setState({myText: 'You swiped down!'});\n  }\n\n  onSwipeLeft(gestureState) {\n    this.setState({myText: 'You swiped left!'});\n  }\n\n  onSwipeRight(gestureState) {\n    this.setState({myText: 'You swiped right!'});\n  }\n\n  onSwipe(gestureName, gestureState) {\n    const {SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT} = swipeDirections;\n    this.setState({gestureName: gestureName});\n    switch (gestureName) {\n      case SWIPE_UP:\n        this.setState({backgroundColor: 'red'});\n        break;\n      case SWIPE_DOWN:\n        this.setState({backgroundColor: 'green'});\n        break;\n      case SWIPE_LEFT:\n        this.setState({backgroundColor: 'blue'});\n        break;\n      case SWIPE_RIGHT:\n        this.setState({backgroundColor: 'yellow'});\n        break;\n    }\n  }\n\n  render() {\n\n    const config = {\n      velocityThreshold: 0.3,\n      directionalOffsetThreshold: 80\n    };\n\n    return (\n      \u003cGestureRecognizer\n        onSwipe={(direction, state) =\u003e this.onSwipe(direction, state)}\n        onSwipeUp={(state) =\u003e this.onSwipeUp(state)}\n        onSwipeDown={(state) =\u003e this.onSwipeDown(state)}\n        onSwipeLeft={(state) =\u003e this.onSwipeLeft(state)}\n        onSwipeRight={(state) =\u003e this.onSwipeRight(state)}\n        config={config}\n        style={{\n          flex: 1,\n          backgroundColor: this.state.backgroundColor\n        }}\n        \u003e\n        \u003cText\u003e{this.state.myText}\u003c/Text\u003e\n        \u003cText\u003eonSwipe callback received gesture: {this.state.gestureName}\u003c/Text\u003e\n      \u003c/GestureRecognizer\u003e\n    );\n  }\n}\n\nexport default SomeComponent;\n```\n\n## Config\n\nCan be passed within optional `config` property.\n\n| Params                     | Type          | Default | Description  |\n| -------------------------- |:-------------:| ------- | ------------ |\n| velocityThreshold          | Number        | 0.3     | Velocity that has to be breached in order for swipe to be triggered (`vx` and `vy` properties of `gestureState`) |\n| directionalOffsetThreshold | Number        | 80      | Absolute offset that shouldn't be breached for swipe to be triggered (`dy` for horizontal swipe, `dx` for vertical swipe) |\n| gestureIsClickThreshold    | Number        | 5       | Absolute distance that should be breached for the gesture to not be considered a click (`dx` or `dy` properties of `gestureState`) |\n\n## Methods\n\n#### onSwipe(gestureName, gestureState)\n\n| Params        | Type          | Description  |\n| ------------- |:-------------:| ------------ |\n| gestureName   | String        | Name of the gesture (look example above) |\n| gestureState  | Object        | gestureState received from PanResponder  |\n\n\n#### onSwipeUp(gestureState)\n\n| Params        | Type          | Description  |\n| ------------- |:-------------:| ------------ |\n| gestureState  | Object        | gestureState received from PanResponder  |\n\n#### onSwipeDown(gestureState)\n\n| Params        | Type          | Description  |\n| ------------- |:-------------:| ------------ |\n| gestureState  | Object        | gestureState received from PanResponder  |\n\n#### onSwipeLeft(gestureState)\n\n| Params        | Type          | Description  |\n| ------------- |:-------------:| ------------ |\n| gestureState  | Object        | gestureState received from PanResponder  |\n\n#### onSwipeRight(gestureState)\n\n| Params        | Type          | Description  |\n| ------------- |:-------------:| ------------ |\n| gestureState  | Object        | gestureState received from PanResponder  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglepur%2Freact-native-swipe-gestures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglepur%2Freact-native-swipe-gestures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglepur%2Freact-native-swipe-gestures/lists"}