Richard
Richard

Reputation: 13

How do I get Flatlist to scroll item to 1

I wanted a full screen list of videos, but I scroll up and down extremely fast.I wish he only had item +1 or -1 at a time, not so many item slides. Do you have any good ideas? Flatlist doesn't seem to have this property.You can't limit the number of slides enter image description here

Upvotes: 1

Views: 2457

Answers (2)

Jimmy Chiang
Jimmy Chiang

Reputation: 66

I recently had the same problem as you, which I want FlatList to scroll one index in one scroll.

First I look at the FlatList props, it seems there are no props that can solve my problem. Then I look up with the ScrollView props, because FlatList inherits ScrollView props.

I found a disableintervalmomentum props which can simply resolve my problem. See more describe at here.

So you can just add the props and set it to true like below:

 <FlatList
  // other props
  disableintervalmomentum:{true}
 />

Upvotes: 5

Rajshekhar
Rajshekhar

Reputation: 614

Can you explain a bit more. For Scrolling one at a time you can use Viewpager. That will be a better approach. I did some modifications that might work.

  <FlatList
    snapToAlignment={"top"}
    viewabilityConfig={{ itemVisiblePercentThreshold: 90 }}
    pagingEnabled={true}
    data={dayOptions}
    decelerationRate={"fast"}
    renderItem={({ item }) => <Render item={item} />}
  />

You can try one more thing on scrollEnabled={false} and scroll it by click on some icon.

Upvotes: 1

Related Questions