meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.27k stars 2.27k forks source link

Question - Collapsable Header #677

Open AAAstorga opened 4 years ago

AAAstorga commented 4 years ago

Is this a bug report, a feature request, or a question?

Question

I am interested in making a collapsable header while using a Carousel in vertical orientation. I have an animated value listening to the onScroll event on the Carousel. As the user scrolls from the first item down, I make the height of the header smaller. This causes the Carousel to jump around and get really glitchy before going back to the first item. Is there a way to achieve a collapsable header without the Carousel spazzing out?

Thanks!

Example:


const headerHeightInterpolation = scrollOffsetY.current.interpolate({
        inputRange: [0, HEADER_SCROLL_DISTANCE],
        outputRange: [EXPANDED_HEADER_HEIGHT, COLLAPSED_HEADER_HEIGHT],
        extrapolate: 'clamp',
});

...

<View>
    <Animated.View style={{flex: 1, height: headerHeightInterpolation, marginBottom: 8}}>
        <Carousel vertical={true} ...restOfProps />
    </Animated.View>
</View>
dohooo commented 2 years ago

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