Skip to content

How to lock Y vs X depending on gesture with the new API? #2254

Answered by npearson72
npearson72 asked this question in Q&A
Discussion options

You must be logged in to vote

I figured it out. The key was to use withRef and activeOffsetX.

Here's the code in case anyone is interested:

import { useRef } from 'react';
import {
  Dimensions,
  Pressable,
  StyleSheet,
  Text,
  SafeAreaView,
  StatusBar
} from 'react-native';
import Animated, {
  useAnimatedStyle,
  useSharedValue,
  withTiming,
  withSpring,
  SharedValue,
  runOnJS
} from 'react-native-reanimated';
import {
  GestureHandlerRootView,
  GestureDetector,
  Gesture,
  ScrollView
} from 'react-native-gesture-handler';

const ITEMS = [
  { id: 1, text: 'Example 1' },
  { id: 2, text: 'Example 2' },
  { id: 3, text: 'Example 3' },
  { id: 4, text: 'Example 4' },
  { id: 5, text: 'Example 5' },
  { id: 6, 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by npearson72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant