question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FlatList pagingEnabled don't work all the time on Android

See original GitHub issue

🐛 Bug Report

So i have an horizontal flatlist where each items use the entire width of the screen. I can swipe between the items. When i do a normal swipe, it works perfectly, the previous item slides out while the next slides in, just as expected The issue is, when i’m dragging the item and leaving the items in a state where both items are visible, the items neither go back to previous item nor to the next and just stuck in between. The pagingEnabled doesn’t work and my screen is stuck in between 2 items.

Expected Behavior

when the dragging is stopped and the user has no longer touching the screen, depends on the viewAreaCoveragePercentThreshold that has been declared or by default 50% for example: if viewAreaCoveragePercentThreshold = 50 then if 50% or more of the next item is visible it should animate to the next item otherwise to the previous item

Code Example

<FlatList
   viewabilityConfig={this.viewabilityConfig}
   ref={(flatList) => (this.flatList = flatList)}
   getItemLayout={(data, index) => ({
   	length : this.state.width,
   	offset : this.state.width * index,
   	index
   })}
   onLayout={this.onLayout}
   data={this.props.data}
   renderItem={this.renderItem}
   keyExtractor={this.keyExtractor}
   horizontal
   pagingEnabled
/>

Environment

info React Native Environment Info: System: OS: Windows 10 CPU: (4) x64 Intel® Core™ i5-3230M CPU @ 2.60GHz Memory: 2.97 GB / 7.85 GB Binaries: npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5264788

“dependencies”: { “react”: “16.8.3”, “react-native”: “0.59.3” }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
gongdao123commented, Apr 16, 2019

Same thing happens to me too.

I can confirm that this only happens on Android.

And if I put tracking code like following:

    <FlatList
        {...this.props}
        ref={this.handleInfListRef}
        data={data}
        getItemLayout={getItemLayout}
        initialScrollIndex={initialScrollIndex}
        pagingEnabled
        renderItem={renderItem}
        onScroll={this.onScroll}
        onTouchStart={() => console.log('onTouchStart')}
        onTouchMove={() => console.log('onTouchMove')}
        onTouchEnd={() => console.log('onTouchEnd')}
        onScrollBeginDrag={() => console.log('onScrollBeginDrag')}
        onScrollEndDrag={() => console.log('onScrollEndDrag')}
        onMomentumScrollBegin={() => console.log('onMomentumScrollBegin')}
        onMomentumScrollEnd={() => console.log('onMomentumScrollEnd')}
        showsHorizontalScrollIndicator={showsHorizontalScrollIndicator}
      />

In normal case (move finger quickly), when I stop dragging the event fires in this order:

onTouchEnd
onScrollEndDrag
onMomentumScrollEnd

But when I move finger slowly only onTouchEnd will be triggered.

0reactions
stale[bot]commented, Sep 22, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native FlatList with 3 cards paging layout - Stack Overflow
if you use pWidth *3 it wont work. Now you may ask why, I really do not understand , it may have something...
Read more >
ScrollView - React Native
FlatList renders items lazily, when they are about to appear, and removes items that scroll way off screen to save memory and processing...
Read more >
react native flatlist infinite loop - You.com | The AI Search ...
The FlatList (paging enabled, horizontal) has 3 to 7 items in the data ... If I run using the debugger, all is well,...
Read more >
Let's create a carousel in React Native - DEV Community ‍ ‍
This is all a part of FlatList default optimizations that work great for longer lists, but not for our use case. So let's...
Read more >
Common bugs in React Native ScrollView and how to fix them
Because FlatList only renders elements that are currently showing on the screen — not all the elements at once — it is capable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found