react-native-snap-carousel icon indicating copy to clipboard operation
react-native-snap-carousel copied to clipboard

Add option to limit number of scrolled items to 1

Open marcmo opened this issue 6 years ago • 8 comments

Is this a bug report or a feature request?

Feature Request

Have you read the guidelines regarding bug report?

Yes

Have you read the documentation in its entirety?

Yes

Description

would be great to enable a mode where users only fling one element at a time: no matter how quick the gesture is, only the next element should be centered. Maybe this is already possible but I haven't found it anywhere in the documentation or the examples.

marcmo avatar Mar 28 '18 07:03 marcmo

Hi @marcmo,

Prop lockScrollWhileSnapping should help with that. Also, make sure to test in a production environment.

To provide a bit more context about why this is not an easy thing to accomplish, you need to know that despite being one of the most wanted feature, the React Native team have not implement yet a proper equivalent of the iOS snapToAlignment/snapToInterval combo on Android. Therefore, we are left with a bunch of hacks, workarounds and debug mode issues... I've done my best to tackle it, but some core things are either missing or buggy and I have no control at all over it.

Still, ideas and PR are always welcome ;-)

bd-arc avatar Mar 28 '18 07:03 bd-arc

thanks for the fast reply @bd-arc ...yes I know about the snapToInterval issue in Android...a pity! that's actually the reason I tried your library ;) I understand that this is not an issue that might not be easy to accomplish so I will close it for now. I did try your lockScrollWhileSnapping property but had no success (still able to scroll more than 1 item when flinging).

marcmo avatar Mar 29 '18 14:03 marcmo

Could we keep this open in case someone else has an alternative solution, I really need this for a project I'm working on :P

CodeLuca avatar Apr 07 '18 10:04 CodeLuca

@CodeLuca Sure, but don't get your hopes too high for now ;-)

Unless the Facebook team implement a proper snapToInterval on Android and make the ScrollView component behave properly on this OS, we're kind of stuck...

FYI, I've been thinking about implementing a custom PanResponder on top of the FlatList to see if I can anyhow get the best of both worlds, but this is more work than I can handle at the moment...

bd-arc avatar Apr 08 '18 16:04 bd-arc

@marcmo @CodeLuca Hi, do you have any solutions ?

cuitianze avatar Aug 19 '19 03:08 cuitianze

@bd-arc Any new solutions or ideas? I have this problem on Android :(

vladlenskiy avatar Jun 18 '21 12:06 vladlenskiy

Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2

dohooo avatar Oct 08 '21 05:10 dohooo

For everyone still looking for a solution.

Use those properties from ScrollView, worked wonders for me.

disableIntervalMomentum pagingEnabled

comvenger-brandon avatar Jul 05 '22 16:07 comvenger-brandon