See the swipeable card on the left? It’s a popular mobile UX pattern used in apps like Google Now.
It’s also surprisingly interesting to implement, performance-wise.
We’re going to implement this example multiple times and see the performance implications of each approach.
It makes sense to create a reusable component Swipeable that adds the swipe behavior (x translation and opacity change) to any content component we give it as child — Card in this case.
Let’s start with the straightforward approach. Since we want to listen on touch gestures, we’ll use React Native’s PanResponder. Every time we receive a move event, we’ll calculate the new opacity and x translation based on the total horizontal distance traveled, and update them using local state:
... read the whole story at medium.com.