{"id":9390,"date":"2024-06-04T10:06:42","date_gmt":"2024-06-04T10:06:42","guid":{"rendered":"https:\/\/dianapps.com\/blog\/?p=9390"},"modified":"2024-06-04T10:07:33","modified_gmt":"2024-06-04T10:07:33","slug":"react-native-gesture-handler-swipe-long-press-and-more","status":"publish","type":"post","link":"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/","title":{"rendered":"React Native Gesture Handler: Swipe, long-press, and more"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Have you ever wondered how with a simple tap on the screen you can pinch, swipe, long press, double tap, and scroll throughout any mobile or web app browser?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It all operates so efficiently through your hand gestures as if you have magical power in your hands. However, the true hero here is the implementation of <\/span><b>\u201cGesture Handlers\u201d<\/b><span style=\"font-weight: 400;\"> that runs in the background of a mobile app allowing users to perceive and engage in an intuitive experience of using mobile phones through their fingers.\u00a0<\/span><\/p>\n<p>React Native app development services<span style=\"font-weight: 400;\">, a popular framework built in JavaScript and React come with its gesture handling system. However, for more complex and performant gesture handling, the React Native Gesture Handler library offers a superior alternative. This library provides a more comprehensive and customizable set of tools for implementing gestures in your React Native apps.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this blog, we will explore how to leverage React Native Gesture Handler to implement common gestures such as swipes and long-presses. We&#8217;ll walk you through the setup process, discuss the basic concepts, and provide step-by-step guides and code examples to help you get started.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Additionally, we&#8217;ll delve into more advanced topics like combining gestures and creating custom gestures, ensuring you have a robust understanding of how to enhance your app&#8217;s interactivity.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">By the end of this guide, you&#8217;ll be well-equipped to create a smoother and more intuitive user experience in your React Native applications.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Setting-Up-React-Native-Gesture-Handler\"><\/span><span style=\"font-weight: 400;\">Setting Up React Native Gesture Handler<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Before we jump to the implementation of gestures in your React Native app, we need to set up the React Native Gesture Handler library. This section will guide you through the prerequisites, installation, and configuration process to make sure everything is ready for you to start handling gestures effortlessly.\u00a0<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span><span style=\"font-weight: 400;\">Prerequisites<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Before setting up the React Native Gesture Handler, make sure you have the following prerequisites:<\/span><\/p>\n<ol>\n<li><b> Node.js:<\/b><span style=\"font-weight: 400;\"> Ensure you have Node.js installed on your machine. You can download it from<\/span><a href=\"https:\/\/nodejs.org\/\"><span style=\"font-weight: 400;\"> nodejs.org<\/span><\/a><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">.\n<p><\/span><\/span><\/li>\n<li><b>React Native environment:<\/b><span style=\"font-weight: 400;\"> Set up a React Native development environment. If you haven&#8217;t done this yet, follow the official React Native Getting Started guide.<\/span><\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Installation-Guide\"><\/span><span style=\"font-weight: 400;\">Installation Guide\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To install React Native Gesture Handler, follow these steps:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400;\"> Use npm or yarn to install the library. Run one of the following commands in your project directory:<\/span><\/li>\n<\/ol>\n<p><b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0npm install react-native-gesture-handler<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Or\u00a0<\/span><\/p>\n<p><b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 yarn add react-native-gesture-handler<\/b><\/p>\n<ol start=\"2\">\n<li><span style=\"font-weight: 400;\"> Configure the package for iOS:\u00a0<\/span><\/li>\n<\/ol>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open the iOS folder of your project in Xcode.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Find your project in the Project <\/span><a href=\"https:\/\/dianapps.com\/blog\/how-to-create-a-bottom-tab-navigator-in-react-native\/\"><span style=\"font-weight: 400;\">Navigator<\/span><\/a><span style=\"font-weight: 400;\"> and select the target.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the Build Phases tab, expand the Link Binary with Libraries section.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Add libRNGestureHandler.a.<\/span><\/li>\n<\/ul>\n<ol start=\"3\">\n<li><span style=\"font-weight: 400;\"> Configure the package for Android:<\/span><\/li>\n<\/ol>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open the android\/app\/src\/main\/java\/&#8230;\/MainActivity.java file and modify it as follows:<\/span><\/li>\n<\/ul>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import com.facebook.react.ReactActivity;\r\n\r\nimport com.facebook.react.ReactActivityDelegate;\r\n\r\nimport com.facebook.react.ReactRootView;\r\n\r\nimport com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;\r\n\r\npublic class MainActivity extends ReactActivity {\r\n\r\n\u00a0\u00a0@Override\r\n\r\n\u00a0\u00a0protected String getMainComponentName() {\r\n\r\n\u00a0\u00a0\u00a0\u00a0return \"YourAppName\";\r\n\r\n\u00a0\u00a0}\r\n\r\n\u00a0\u00a0@Override\r\n\r\n\u00a0\u00a0protected ReactActivityDelegate createReactActivityDelegate() {\r\n\r\n\u00a0\u00a0\u00a0\u00a0return new ReactActivityDelegate(this, getMainComponentName()) {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0@Override\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0protected ReactRootView createRootView() {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return new RNGestureHandlerEnabledRootView(MainActivity.this);\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0\u00a0\u00a0};\r\n\r\n\u00a0\u00a0}\r\n\r\n}<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Verifying-Installation\"><\/span><span style=\"font-weight: 400;\">Verifying Installation<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">After installing and configuring the package, it&#8217;s important to verify that everything is set up correctly. Run your React Native application on both iOS and Android to ensure that there are no errors related to the gesture handler. You can do this by executing the following command:<\/span><\/p>\n<p><b>npx react-native run-android<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Or<\/span><\/p>\n<p><b>npx react-native run-ios<\/b><\/p>\n<p><span style=\"font-weight: 400;\">If your application runs without any issues, you&#8217;ve successfully set up React Native Gesture Handler and can proceed to implement various gestures.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Basic-Concepts-of-React-Native-Gesture-Handler\"><\/span><span style=\"font-weight: 400;\">Basic Concepts of React Native Gesture Handler<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"GestureHandlerRootView\"><\/span><span style=\"font-weight: 400;\">GestureHandlerRootView\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><b>GestureHandlerRootView<\/b><span style=\"font-weight: 400;\"> is a container component that needs to wrap your entire app or the part of your app where you intend to use gesture handlers. It ensures that gesture handling is managed correctly and efficiently by the library. Without this component, gestures may not work as expected.<\/span><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import { GestureHandlerRootView } from 'react-native-gesture-handler';\r\n\r\nconst App = () =&gt; {\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;GestureHandlerRootView style={{ flex: 1 }}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\/* Your app components *\/}\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/GestureHandlerRootView&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};\r\n\r\nexport default App;<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"GestureDetector\"><\/span><span style=\"font-weight: 400;\">GestureDetector<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><b>GestureDetector<\/b><span style=\"font-weight: 400;\"> is used to combine multiple gestures and manage their interactions seamlessly. It acts as a higher-level component that can contain multiple gesture handlers and ensures they work together without conflicts.<\/span><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import { GestureDetector, Gesture, GestureHandlerRootView } from 'react-native-gesture-handler';\r\n\r\nconst Example = () =&gt; {\r\n\r\n\u00a0\u00a0const swipeGesture = Gesture.Swipe().onEnd((event) =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\/\/ Handle swipe end\r\n\r\n\u00a0\u00a0});\r\n\r\n\u00a0\u00a0const longPressGesture = Gesture.LongPress().onEnd((event) =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\/\/ Handle long press end\r\n\r\n\u00a0\u00a0});\r\n\r\n\u00a0\u00a0const composedGesture = Gesture.Exclusive(swipeGesture, longPressGesture);\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;GestureHandlerRootView style={{ flex: 1 }}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;GestureDetector gesture={composedGesture}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;View style={{ width: 100, height: 100, backgroundColor: 'blue' }} \/&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/GestureDetector&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/GestureHandlerRootView&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"GestureStateManager\"><\/span><span style=\"font-weight: 400;\">GestureStateManager<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">GestureStateManager is used to manually control the state of a gesture. This can be useful in scenarios where you need to programmatically start, update, or stop a gesture.<\/span><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import { GestureStateManager } from 'react-native-gesture-handler';\r\n\r\nconst stateManager = GestureStateManager.create();\r\n\r\nconst panGesture = Gesture.Pan()\r\n\r\n\u00a0\u00a0.withRef(stateManager)\r\n\r\n\u00a0\u00a0.onUpdate((event) =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0if (event.translationX &gt; 100) {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0stateManager.end();\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0});<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"FlingGestureHandler\"><\/span><span style=\"font-weight: 400;\">FlingGestureHandler<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><b>FlingGestureHandler<\/b><span style=\"font-weight: 400;\"> detects a quick swipe gesture in a specific direction. It is useful for implementing fling actions, such as dismissing items or navigating between screens.<\/span><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import { FlingGestureHandler, Directions } from 'react-native-gesture-handler';\r\n\r\nconst Example = () =&gt; {\r\n\r\n\u00a0\u00a0const onFling = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0console.log('Fling detected');\r\n\r\n\u00a0\u00a0};\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;FlingGestureHandler direction={Directions.UP} onActivated={onFling}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;View style={{ width: 100, height: 100, backgroundColor: 'red' }} \/&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/FlingGestureHandler&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"PinchGestureHandler-and-RotationGestureHandler\"><\/span><span style=\"font-weight: 400;\">PinchGestureHandler and RotationGestureHandler<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">For handling multi-touch gestures like pinch-to-zoom and rotation, React Native Gesture Handler provides <\/span><b>PinchGestureHandler <\/b><span style=\"font-weight: 400;\">and<\/span><b> RotationGestureHandler.<\/b><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import { PinchGestureHandler, RotationGestureHandler } from 'react-native-gesture-handler';\r\n\r\nconst Example = () =&gt; {\r\n\r\n\u00a0\u00a0const onPinch = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0console.log('Pinch detected', event.scale);\r\n\r\n\u00a0\u00a0};\r\n\r\n\u00a0\u00a0const onRotate = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0console.log('Rotation detected', event.rotation);\r\n\r\n\u00a0\u00a0};\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;PinchGestureHandler onGestureEvent={onPinch}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;RotationGestureHandler onGestureEvent={onRotate}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;View style={{ width: 100, height: 100, backgroundColor: 'yellow' }} \/&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/RotationGestureHandler&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/PinchGestureHandler&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Animated-Gesture-Handlers\"><\/span><span style=\"font-weight: 400;\">Animated Gesture Handlers<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><img decoding=\"async\" class=\"wp-image-9395  aligncenter\" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/final-f203d12bb467795e7825d7dd2a911aad.gif\" alt=\"\" width=\"444\" height=\"417\" \/><\/p>\n<p><span style=\"font-weight: 400;\">React Native Gesture Handler integrates well with the Reanimated library, allowing you to create smooth, performant animations in response to gestures.<\/span><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import { GestureDetector, Gesture } from 'react-native-gesture-handler';\r\n\r\nimport Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated';\r\n\r\nconst Example = () =&gt; {\r\n\r\n\u00a0\u00a0const translationX = useSharedValue(0);\r\n\r\n\u00a0\u00a0const translationY = useSharedValue(0);\r\n\r\n\u00a0\u00a0const panGesture = Gesture.Pan()\r\n\r\n\u00a0\u00a0\u00a0\u00a0.onUpdate((event) =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0translationX.value = event.translationX;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0translationY.value = event.translationY;\r\n\r\n\u00a0\u00a0\u00a0\u00a0})\r\n\r\n\u00a0\u00a0\u00a0\u00a0.onEnd(() =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0translationX.value = withSpring(0);\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0translationY.value = withSpring(0);\r\n\r\n\u00a0\u00a0\u00a0\u00a0});\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0const animatedStyle = useAnimatedStyle(() =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0return {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0transform: [\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ translateX: translationX.value },\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{ translateY: translationY.value }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\r\n\r\n\u00a0\u00a0\u00a0\u00a0};\r\n\r\n\u00a0\u00a0});\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;GestureHandlerRootView style={{ flex: 1 }}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;GestureDetector gesture={panGesture}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Animated.View style={[{ width: 100, height: 100, backgroundColor: 'blue' }, animatedStyle]} \/&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/GestureDetector&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/GestureHandlerRootView&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Handling-Common-React-Native-Gestures\"><\/span><span style=\"font-weight: 400;\">Handling Common React Native Gestures<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">With the basic concepts in place, it&#8217;s time to delve into handling common gestures such as swipes, long presses, and taps. React Native Gesture Handler makes it straightforward to implement these gestures, enhancing the interactivity and user experience of your app.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"TapGestureHandler\"><\/span><span style=\"font-weight: 400;\">TapGestureHandler<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><img decoding=\"async\" class=\"wp-image-9397  aligncenter\" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/img2-React-Native-Gesture-Handler-Tap-gesture-handler-demo-2.gif\" alt=\"\" width=\"276\" height=\"584\" \/><\/p>\n<p><b>TapGestureHandler <\/b><span style=\"font-weight: 400;\">is a specific gesture handler for detecting tap gestures. It supports single taps, double taps, and more complex tap patterns. This handler is essential for implementing tap-based interactions, such as button presses or card selections.<\/span><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import { TapGestureHandler } from 'react-native-gesture-handler';\r\n\r\nconst Example = () =&gt; {\r\n\r\n\u00a0\u00a0const onSingleTap = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0console.log('Single tap detected');\r\n\r\n\u00a0\u00a0};\r\n\r\n\u00a0\u00a0const onDoubleTap = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0console.log('Double tap detected');\r\n\r\n\u00a0\u00a0};\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;TapGestureHandler onActivated={onSingleTap} numberOfTaps={1}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;TapGestureHandler onActivated={onDoubleTap} numberOfTaps={2}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;View style={{ width: 100, height: 100, backgroundColor: 'green' }} \/&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/TapGestureHandler&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/TapGestureHandler&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Swipe-Gesture\"><\/span><span style=\"font-weight: 400;\">Swipe Gesture<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Swiping is a common gesture used for navigation or triggering actions. The <\/span><b>PanGestureHandler <\/b><span style=\"font-weight: 400;\">is typically used to detect swipes. You can configure it to detect horizontal or vertical swipes and respond accordingly.<\/span><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-9398 size-full\" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/1_9P448Tihmxn-hh_-BFKjlA-1.gif\" alt=\"\" width=\"600\" height=\"181\" \/><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true \">import React from 'react';\r\n\r\nimport { View, Text, StyleSheet } from 'react-native';\r\n\r\nimport { GestureHandlerRootView, PanGestureHandler } from 'react-native-gesture-handler';\r\n\r\nimport Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated';\r\n\r\nconst SwipeExample = () =&gt; {\r\n\r\n\u00a0\u00a0const translateX = useSharedValue(0);\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0const onGestureEvent = (event) =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0translateX.value = event.translationX;\r\n\r\n\u00a0\u00a0};\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0const onHandlerStateChange = (event) =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0if (event.nativeEvent.state === 5) { \/\/ 5 corresponds to \"end\" state\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0translateX.value = withSpring(0);\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0};\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0const animatedStyle = useAnimatedStyle(() =&gt; ({\r\n\r\n\u00a0\u00a0\u00a0\u00a0transform: [{ translateX: translateX.value }],\r\n\r\n\u00a0\u00a0}));\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;GestureHandlerRootView style={styles.container}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;PanGestureHandler onGestureEvent={onGestureEvent} onHandlerStateChange={onHandlerStateChange}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Animated.View style={[styles.box, animatedStyle]}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Text&gt;Swipe Me&lt;\/Text&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/Animated.View&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/PanGestureHandler&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/GestureHandlerRootView&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};\r\n\r\n\r\n\r\n\r\nconst styles = StyleSheet.create({\r\n\r\n\u00a0\u00a0container: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0flex: 1,\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n\u00a0\u00a0box: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0width: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0height: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0backgroundColor: 'lightblue',\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n});\r\n\r\n\r\n\r\n\r\nexport default SwipeExample;<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Long-Press-Gesture\"><\/span><span style=\"font-weight: 400;\">Long Press Gesture<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Long pressing is used to reveal additional options or to confirm an action. The <\/span><b>LongPressGestureHandler <\/b><span style=\"font-weight: 400;\">is designed to detect long presses and can be customized with properties like minDurationMs to specify the minimum duration of the press.<\/span><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-9399 \" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/single-tap-gesture.gif\" alt=\"\" width=\"246\" height=\"531\" \/><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import React from 'react';\r\n\r\nimport { View, Text, StyleSheet, Alert } from 'react-native';\r\n\r\nimport { GestureHandlerRootView, LongPressGestureHandler } from 'react-native-gesture-handler';\r\n\r\n\r\n\r\n\r\nconst LongPressExample = () =&gt; {\r\n\r\n\u00a0\u00a0const onLongPress = () =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0Alert.alert('Long Press Detected', 'You have long-pressed the box.');\r\n\r\n\u00a0\u00a0};\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;GestureHandlerRootView style={styles.container}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;LongPressGestureHandler onActivated={onLongPress} minDurationMs={800}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;View style={styles.box}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Text&gt;Long Press Me&lt;\/Text&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/View&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/LongPressGestureHandler&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/GestureHandlerRootView&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};\r\n\r\n\r\n\r\n\r\nconst styles = StyleSheet.create({\r\n\r\n\u00a0\u00a0container: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0flex: 1,\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n\u00a0\u00a0box: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0width: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0height: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0backgroundColor: 'lightcoral',\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n});\r\n\r\n\r\n\r\n\r\nexport default LongPressExample;<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Pinch-to-Zoom-Gesture\"><\/span><span style=\"font-weight: 400;\">Pinch-to-Zoom Gesture\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Pinching is commonly used for zooming in and out, typically in image galleries, maps, or any interface that benefits from zoom functionality. The PinchGestureHandler detects pinch gestures and provides properties such as scale to determine the zoom level.<\/span><\/p>\n<p><img decoding=\"async\" class=\"wp-image-9400  aligncenter\" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/1_AgRorpXREtq4fwyF9qMpJw.gif\" alt=\"\" width=\"231\" height=\"476\" \/><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import React from 'react';\r\n\r\nimport { View, Text, StyleSheet } from 'react-native';\r\n\r\nimport { GestureHandlerRootView, PinchGestureHandler } from 'react-native-gesture-handler';\r\n\r\nimport Animated, { useSharedValue, useAnimatedStyle } from 'react-native-reanimated';\r\n\r\nconst PinchExample = () =&gt; {\r\n\r\n\u00a0\u00a0const scale = useSharedValue(1);\r\n\r\n\u00a0\u00a0const onGestureEvent = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0scale.value = event.scale;\r\n\r\n\u00a0\u00a0};\r\n\r\n\u00a0\u00a0const animatedStyle = useAnimatedStyle(() =&gt; ({\r\n\r\n\u00a0\u00a0\u00a0\u00a0transform: [{ scale: scale.value }],\r\n\r\n\u00a0\u00a0}));\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;GestureHandlerRootView style={styles.container}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;PinchGestureHandler onGestureEvent={onGestureEvent}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Animated.View style={[styles.box, animatedStyle]}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Text&gt;Pinch Me&lt;\/Text&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/Animated.View&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/PinchGestureHandler&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/GestureHandlerRootView&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n\r\n\u00a0\u00a0container: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0flex: 1,\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n\u00a0\u00a0box: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0width: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0height: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0backgroundColor: 'lightpink',\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n});\r\n\r\nexport default PinchExample;<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Pan-Gesture\"><\/span><span style=\"font-weight: 400;\">Pan Gesture<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">The PanGestureHandler detects panning movements, allowing you to track the position of the user&#8217;s finger and translate elements accordingly. It&#8217;s commonly used for draggable items or swipe-to-dismiss features.<\/span><\/p>\n<p><img decoding=\"async\" class=\"wp-image-9401  aligncenter\" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/img1-React-Native-Gesture-Handler-Pan-gesture-handler-demo-1.gif\" alt=\"\" width=\"213\" height=\"461\" \/><\/p>\n<pre class=\"theme:github font-size:14 nums:false lang:default decode:true\">import React from 'react';\r\n\r\nimport { View, Text, StyleSheet } from 'react-native';\r\n\r\nimport { GestureHandlerRootView, PanGestureHandler } from 'react-native-gesture-handler';\r\n\r\nimport Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated';\r\n\r\n\r\n\r\n\r\nconst PanExample = () =&gt; {\r\n\r\n\u00a0\u00a0const translateX = useSharedValue(0);\r\n\r\n\u00a0\u00a0const translateY = useSharedValue(0);\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0const onGestureEvent = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0translateX.value = event.translationX;\r\n\r\n\u00a0\u00a0\u00a0\u00a0translateY.value = event.translationY;\r\n\r\n\u00a0\u00a0};\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0const onHandlerStateChange = event =&gt; {\r\n\r\n\u00a0\u00a0\u00a0\u00a0if (event.nativeEvent.state === 5) { \/\/ 5 corresponds to \"end\" state\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0translateX.value = withSpring(0);\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0translateY.value = withSpring(0);\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0};\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0const animatedStyle = useAnimatedStyle(() =&gt; ({\r\n\r\n\u00a0\u00a0\u00a0\u00a0transform: [{ translateX: translateX.value }, { translateY: translateY.value }],\r\n\r\n\u00a0\u00a0}));\r\n\r\n\r\n\r\n\r\n\u00a0\u00a0return (\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;GestureHandlerRootView style={styles.container}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;PanGestureHandler onGestureEvent={onGestureEvent} onHandlerStateChange={onHandlerStateChange}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Animated.View style={[styles.box, animatedStyle]}&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;Text&gt;Drag Me&lt;\/Text&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/Animated.View&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/PanGestureHandler&gt;\r\n\r\n\u00a0\u00a0\u00a0\u00a0&lt;\/GestureHandlerRootView&gt;\r\n\r\n\u00a0\u00a0);\r\n\r\n};\r\n\r\n\r\n\r\n\r\nconst styles = StyleSheet.create({\r\n\r\n\u00a0\u00a0container: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0flex: 1,\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n\u00a0\u00a0box: {\r\n\r\n\u00a0\u00a0\u00a0\u00a0width: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0height: 150,\r\n\r\n\u00a0\u00a0\u00a0\u00a0backgroundColor: 'lightgreen',\r\n\r\n\u00a0\u00a0\u00a0\u00a0justifyContent: 'center',\r\n\r\n\u00a0\u00a0\u00a0\u00a0alignItems: 'center',\r\n\r\n\u00a0\u00a0},\r\n\r\n});\r\n\r\nexport default PanExample;<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Troubleshooting-and-Best-Practices\"><\/span><span style=\"font-weight: 400;\">Troubleshooting and Best Practices<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Implementing gesture handling in React Native can sometimes be challenging due to various factors such as conflicting gestures, performance issues, or unexpected behavior. This section will provide troubleshooting tips and best practices to help you overcome common issues and ensure a smooth user experience.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Also read: <\/span><a href=\"https:\/\/dianapps.com\/blog\/common-debugging-and-troubleshooting-of-react-native-apps\/\"><span style=\"font-weight: 400;\">Debugging and troubleshooting of React Native Apps<\/span><\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Gesture-Conflicts\"><\/span><span style=\"font-weight: 400;\">Gesture Conflicts<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><img decoding=\"async\" class=\"wp-image-9402  aligncenter\" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/53846776-33c52a00-3fe9-11e9-83fc-70cc0ed03a84.gif\" alt=\"\" width=\"220\" height=\"469\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Identifying conflicting gestures is crucial for seamless interaction in React Native applications. When multiple gesture handlers are active simultaneously, conflicts can arise, impacting user experience.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It&#8217;s essential to prioritize gestures based on their importance and potential conflicts. Strategies like using simultaneous, exclusive, or race gestures can help manage conflicts effectively.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Additionally, nesting gesture handlers should be avoided as it may lead to unexpected behavior.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">By combining gestures or using a single gesture handler for complex interactions, conflicts can be minimized, ensuring smooth user interactions.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Performance-Optimization\"><\/span><span style=\"font-weight: 400;\">Performance Optimization<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/dianapps.com\/blog\/how-to-improve-the-performance-of-a-react-native-app\/\"><span style=\"font-weight: 400;\">Improve performance in react native apps<\/span><\/a><span style=\"font-weight: 400;\"> is vital for delivering a responsive user experience in React Native applications. Minimizing the number of gesture recognizers helps reduce the computational overhead and enhances performance.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Debouncing or throttling gesture events can prevent excessive updates, especially in complex interactions. Moreover, optimizing animations created with Reanimated by reducing unnecessary re-renders and heavy computations can further improve performance and responsiveness.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Handling-Edge-Cases\"><\/span><span style=\"font-weight: 400;\">Handling Edge Cases<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><img decoding=\"async\" class=\"wp-image-9403  aligncenter\" src=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/1_JvQG9PD7qvD3zhHq-gpc_w.gif\" alt=\"\" width=\"414\" height=\"559\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Properly handling edge cases ensures robust gesture handling in React Native applications. It&#8217;s essential to handle gesture state transitions, such as began, active, and end, to maintain the desired behavior and prevent unexpected outcomes.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Implementing fallback mechanisms for scenarios where gestures fail or are not recognized ensures a consistent user experience across different devices and environments.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Testing gesture-based interactions on real devices helps identify and address device-specific issues or inconsistencies effectively.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Accessibility-Considerations\"><\/span><span style=\"font-weight: 400;\">Accessibility Considerations<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Supporting accessibility features is crucial for ensuring inclusive gesture-based interactions in React Native applications.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Providing alternative navigation methods or accessibility labels for gestures makes them accessible to all users, including those with disabilities. Testing gestures with accessibility tools and performing manual testing helps verify compatibility with screen readers and other assistive technologies, ensuring accessibility standards are met.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Documentation-and-Community-Support\"><\/span><span style=\"font-weight: 400;\">Documentation and Community Support<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Referring to official documentation and engaging with the React Native community forums and resources are valuable for troubleshooting and best practices.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The official documentation of React Native Gesture Handler and Reanimated provides comprehensive guides, API references, and troubleshooting tips.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Engaging with the community forums, GitHub repositories, and online resources enables developers to seek assistance, share insights, and stay updated on best practices and the latest developments in gesture handling.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><span style=\"font-weight: 400;\">Conclusion\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Gesture implementation in React Native may enhance user experience and provide users with more intuitive app navigation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The implementation and handling of gestures, such as swipeable, pan, double- and single-tap, pinch-to-zoom, and more, in a React Native application were discussed in this blog post.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This whole codebase example is accessible on GitHub. In case you need assistance integration gesture handling functionality in your mobile app, hire a <\/span><a href=\"https:\/\/dianapps.com\/react-native-app-development\"><b>React Native app development company <\/b><\/a><span style=\"font-weight: 400;\">like DianApps and leave the rest to us. <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wondered how with a simple tap on the screen you can pinch, swipe, long press, double tap, and scroll throughout any mobile or web app browser?\u00a0 It all operates so efficiently through your hand gestures as if you have magical power in your hands. However, the true hero here is the implementation [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":9406,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_wp_applaud_exclude":false,"footnotes":""},"categories":[3],"tags":[83,136,660],"class_list":["post-9390","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-app-development","tag-mobile-app-development","tag-react-native-app","tag-react-native-gesture-handler"],"featured_image_src":{"landsacpe":["https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/Blog-image-1140x445.jpg",1140,445,true],"list":["https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/Blog-image-463x348.jpg",463,348,true],"medium":["https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/Blog-image-300x169.jpg",300,169,true],"full":["https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/Blog-image.jpg",2048,1152,false]},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>React Native Gesture Handler: Swipe, long-press, and more<\/title>\n<meta name=\"description\" content=\"Discover how to implement swipe, long-press, and other gestures in your app with React Native Gesture Handler. Enhance user interactions effortlessly\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React Native Gesture Handler: Swipe, long-press, and more\" \/>\n<meta property=\"og:description\" content=\"Discover how to implement swipe, long-press, and other gestures in your app with React Native Gesture Handler. Enhance user interactions effortlessly\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn About Digital Transformation &amp; Development | DianApps Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-04T10:06:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-04T10:07:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/Blog-image.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2048\" \/>\n\t<meta property=\"og:image:height\" content=\"1152\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Harshita Sharma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Harshita Sharma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"React Native Gesture Handler: Swipe, long-press, and more","description":"Discover how to implement swipe, long-press, and other gestures in your app with React Native Gesture Handler. Enhance user interactions effortlessly","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/","og_locale":"en_US","og_type":"article","og_title":"React Native Gesture Handler: Swipe, long-press, and more","og_description":"Discover how to implement swipe, long-press, and other gestures in your app with React Native Gesture Handler. Enhance user interactions effortlessly","og_url":"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/","og_site_name":"Learn About Digital Transformation &amp; Development | DianApps Blog","article_published_time":"2024-06-04T10:06:42+00:00","article_modified_time":"2024-06-04T10:07:33+00:00","og_image":[{"width":2048,"height":1152,"url":"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2024\/06\/Blog-image.jpg","type":"image\/jpeg"}],"author":"Harshita Sharma","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Harshita Sharma","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/","url":"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/","name":"React Native Gesture Handler: Swipe, long-press, and more","isPartOf":{"@id":"https:\/\/dianapps.com\/blog\/#website"},"datePublished":"2024-06-04T10:06:42+00:00","dateModified":"2024-06-04T10:07:33+00:00","author":{"@id":"https:\/\/dianapps.com\/blog\/#\/schema\/person\/6672b5142fe10cc5379a72656c884045"},"description":"Discover how to implement swipe, long-press, and other gestures in your app with React Native Gesture Handler. Enhance user interactions effortlessly","breadcrumb":{"@id":"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dianapps.com\/blog\/react-native-gesture-handler-swipe-long-press-and-more\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dianapps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"React Native Gesture Handler: Swipe, long-press, and more"}]},{"@type":"WebSite","@id":"https:\/\/dianapps.com\/blog\/#website","url":"https:\/\/dianapps.com\/blog\/","name":"Learn About Digital Transformation &amp; Development | DianApps Blog","description":"Dianapps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dianapps.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/dianapps.com\/blog\/#\/schema\/person\/6672b5142fe10cc5379a72656c884045","name":"Harshita Sharma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dianapps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2025\/04\/unnamed-96x96.png","contentUrl":"https:\/\/dianapps.com\/blog\/wp-content\/uploads\/2025\/04\/unnamed-96x96.png","caption":"Harshita Sharma"},"description":"A competent and enthusiastic writer, having excellent persuasive skills in the tech, marketing, and event industry. With vast knowledge about the latest industry trends, she is familiar with creating engaging content gigs.","sameAs":["https:\/\/www.linkedin.com\/in\/harshita-sharma-958662198"],"url":"https:\/\/dianapps.com\/blog\/author\/harshita\/"}]}},"_links":{"self":[{"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/posts\/9390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/comments?post=9390"}],"version-history":[{"count":8,"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/posts\/9390\/revisions"}],"predecessor-version":[{"id":9407,"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/posts\/9390\/revisions\/9407"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/media\/9406"}],"wp:attachment":[{"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/media?parent=9390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/categories?post=9390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dianapps.com\/blog\/wp-json\/wp\/v2\/tags?post=9390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}