onGestureEvent not working on FlatList
See original GitHub issueI’m trying to get the gesture from a FlatList
because I need the translation.y
and not the contentOffset.y
given by onScroll event. This is because I’m translating the FlatList
and hiding the header as the user scrolls and using the offset provokes glitches (video and source code)
Current FlatList types says props can include NativeViewGestureHandlerProperties
, this means onGestureEvent
and onHandlerStateChange
are available. So this is posible:
import { FlatList } from "react-native-gesture-handler";
<FlatList
onGestureEvent={() => console.log("onGestureEvent")}
onHandlerStateChange={() => console.log("onHandlerStateChange")}
keyExtractor={keyExtractor}
data={data}
renderItem={renderItem}
/>
The truth is neither onGestureEvent or onHandlerStateChange are called as you scroll.
I’m using latest version of react-native-gesture-handler
(v1.6.1) and this is my stack:
System:
OS: macOS 10.15.5
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v12.14.1/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
npmPackages:
expo: ~37.0.3 => 37.0.12
react: ~16.9.0 => 16.9.0
react-dom: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4
react-native-web: ~0.11.7 => 0.11.7
npmGlobalPackages:
expo-cli: 3.21.12
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
React Native Gesture Handler + Reanimated Flat List Scroll
I'm having a problem with react-native-gesture handler animation in a FlatList. when i try to scroll on the flatList the behavior of ...
Read more >React Native Gesture Handler: Swipe, long-press, and more
Implementing gestures in a React Native app improves the user experience. Learn how to create swipeable, pan, long-press, and other ...
Read more >About Gesture Handlers | React Native ... - Software Mansion
Gesture handler components do not instantiate a native view in the view ... Keep in mind that onGestureEvent is only generated in continuous...
Read more >Troubleshooting | React Native Bottom Sheet - GitHub Pages
Adding horizontal FlatList or ScrollView is not working properly on Android. Due to wrapping the content and handle with TapGestureHandler & PanGestureHandler ...
Read more >react-native-gesture-handler is not updating value after ...
Coding example for the question react-native-gesture-handler is not updating value after movement ... <PanGestureHandler onGestureEvent={gestureHandler} ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To anyone reading this:
You can wrap a
FlatList
(imported fromreact-native
) usingPanGestureHandler
as described here: https://github.com/software-mansion/react-native-gesture-handler/issues/492But, this issue stills valid. Types are wrong,
FlatList
byreact-native-gesture-handler
don’t implements eitheronHandlerStateChange
noronGestureEvent
.Note that FlatList must be a child of NativeViewGestureHandler otherwise, it won’t work