kkemple/react-native-sideswipe

Why not use pagingEnabled and Animated.event

zachgibson opened this issue · 5 comments

I’m curious, why didn’t you choose to use the prop pagingEnabled on FlatList for snapping? Also why not use Animated.event and leverage useNativeDriver instead of setValue for mapping your Animated.Value?

why didn’t you choose to use the prop pagingEnabled on FlatList for snapping

because paging enabled is in relation to the scrollview window, not the children, so the scroll view width has to match 1:1 with the child width for that to work which makes most common carousel layouts very difficult

Also why not use Animated.event and leverage useNativeDriver instead of setValue for mapping your Animated.Value

That was actually supposed to be in 1.0.0 and was missed and is now released under 1.1.0, thanks for catching that actually.

going to close this, if you have any more questions just re-open

because paging enabled is in relation to the scrollview window, not the children, so the scroll view width has to match 1:1 with the child width for that to work which makes most common carousel layouts very difficult

This isn’t totally true, but your issue is. Paging enabled will snap to multiples of the scroll view’s size, independent of children. You can achieve the peeking carousel items but the scroll view has to be less width than device width, centered, and overflow set to visible. This works except the edges are no longer scrollable.

Anyways, just wanted to bring up a couple of these things to try and help. Good job on the lightweight carousel!

This isn’t totally true, but your issue is. Paging enabled will snap to multiples of the scroll view’s size, independent of children. You can achieve the peeking carousel items but the scroll view has to be less width than device width, centered, and overflow set to visible. This works except the edges are no longer scrollable.

I completely agree but we have to support large tablet devices and some items in carousel are max 250 dp wide which gets really hard to manage and requires a bit of work around! The other issue is some data sets are quite large and having to swipe through without velocity would get very tedious.

Thanks so much for the brainstorming sesh and love your work in RN eco-system!!

Thanks so much for the brainstorming sesh and love your work in RN eco-system!!

For sure! Wow thanks man, appreciate that. 😃