From the course: React Native Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Handling swipe gestures

Handling swipe gestures - React Native Tutorial

From the course: React Native Essential Training

Start my 1-month free trial

Handling swipe gestures

- [Instructor] We are swiping left and right, but we now need to handle the swipe. What is going to happen when a swipe is complete? And if you remember, we can do operations after an animation is complete using the callback argument for the start method. So in here, this is the function we're going to handle the swipe. So I'll go ahead and write a new function for handling swipe. We'll call this function handleSwipe, and I'll just call it here. And eventually the handleSwipe is going to be different if we're swiping left and right, but let's start with a simple handle swipe left. We'll define handleSwipe. This is a function, in this function, we want to do two things. First, we want to update the state and change the image index that makes the view change its content, and then we want to animate the same view that is holding the image that we swiped completely to the left, we want to animate it from the right. So…

Contents