-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Gesture Handling Enhancement for use with FlatList #104
Comments
@coofzilla Indeed, this is an ugly one... Not sure if I can find a good fix, but perhaps we can workaround it. I'm still looking into it. Will let you know if I find something useful. Related: facebook/react-native#28135 |
@coofzilla What do you think about the following fix? The export const VideoList = () => {
const flatListRef = useRef<FlatList>(null);
return (
<FlatList
ref={flatListRef}
data={videos}
horizontal
renderItem={({ item }) => (
<View>
<VideoPlayer
parentListRef={flatListRef}
source={{ uri: item.url }}
// Other necessary props
/>
</View>
)}
/>
)
} The issue with this approach is that if the developers are using |
Looks good to me, especially since you've documented the change—this will give developers a clear example to follow when implementing it. Just to clarify, would this approach work the same way for VideoPlayers inside FlatLists or ScrollViews that are vertical? Essentially, the same snippet you provided, but without |
@coofzilla Yes, I think so. I will update the PR today and you'll be able to test it in |
@coofzilla The branch is updated. The final implementation is like this: export const VideoList = () => {
const flatListRef = useRef<FlatList>(null);
const [scrollEnabled, setScrollEnabled] = useState<boolean>(true)
return (
<FlatList
ref={flatListRef}
scrollEnabled={scrollEnabled}
data={videos}
horizontal
renderItem={({ item }) => (
<View>
<VideoPlayer
pan={{
parentList: {
ref: flatListRef,
scrollEnabled: scrollEnabled, // This is optional and only needed if `scrollEnabled` prop is used with FlatList
},
}}
source={{uri: 'https://vjs.zencdn.net/v/oceans.mp4'}}
/>
</View>
)}
/>
)
} You can test those changes in Let me know if this fixes your issues |
Problem
When embedding the
VideoPlayer
component within a horizontally scrollingFlatList
, there is a gesture conflict that arises. Specifically, when attempting to seek in the video (or volume) by dragging the seeker control left or right, theFlatList
interprets this gesture as a horizontal scroll, leading to an unintended navigation away from the current video item instead of seeking within the video.Expected Behavior
The expected behavior is that when interacting with the video player's seeking controls, the
FlatList
scrolling should be temporarily disabled or the gesture should be captured exclusively by the video player, allowing for a smooth seeking experience without triggering a scroll in theFlatList
.Current Workaround
Still trying to figure this out 😅
Example Snippet
Here is a simplified code snippet demonstrating the setup:
The text was updated successfully, but these errors were encountered: