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.25k stars 2.26k forks source link

Carousel slide animations not working when inside a Animated.View #543

Open mkrotel14 opened 5 years ago

mkrotel14 commented 5 years ago

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

bug

Have you followed the required steps before opening a bug report?

(Check the step you've followed - put an x character between the square brackets ([]).)

Have you made sure that it wasn't a React Native bug?

Yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

IOS works flawlessly, but on Android it doesn't work at all, just one animation at time

Is the bug reproductible in a production environment (not a debug one)?

The app crashes at production, but on debug you can see that the animations doesn't work

Environment

"react": "16.8.3", "react-native": "0.59.8", "react-native-snap-carousel": "^3.8.0",

Target Platform: Android (9.0) iOS (12)

Expected Behavior

Expected to have a translateY animation for the entire carousel, and the slide animation of the carousel itself

Actual Behavior

If I put the Carousel inside a Animated.View with a translateY with pointerEvents: 'box-only' the translateY works, but, if I set pointerEvets: 'box-none' only the carousel animation work normally, the animations didn't work together

Reproducible Demo

<PanGestureHandler
            onGestureEvent={animatedEvent}
            onHandlerStateChange={onHandlerStateChanged}
          >
            <Animated.View
              pointerEvents='auto'
              style={{
                flex: 1,
                borderRadius: 5,
                position: 'absolute',
                height: '100%',
                left: 0,
                right: 0,
                transform: [{
                  translateY: translateY.interpolate({
                    inputRange: [0, 350],
                    outputRange: [0, 350],
                    extrapolate: 'clamp',
                  }),
                }],
              }}
            >
              <Carousel
                layout="default"
                useScrollView={false}
                data={data}
                itemWidth={(Platform.OS === 'ios') ? totalWidth(width) - 40 : totalWidth(width)}
                sliderWidth={width}
                renderItem={({ item, index }) => (
                  <DataCard
                    key={index}
                  >
                    <CardImage>
                      <Image source={logo} />
                    </CardImage>
                    <CardFooter>
                      <Title>{item.title.toUpperCase()}</Title>
                      <Subtitle>{item.subtitle}</Subtitle>
                    </CardFooter>
                  </DataCard>
                )}
              />
            </Animated.View>
          </PanGestureHandler>
anisfrontmen commented 5 years ago

+1

mkrotel14 commented 4 years ago

I managed to get the carousel to work, but I have to perform a double click action , Is there another way to do?

philipeneves commented 4 years ago

Same problem here, any solution?

mkrotel14 commented 4 years ago

I kind abandoned the way I was doing inside a Animation.View and made a rework at my screen to fit all the necessary infos. At the time I didn't get any response for this problem

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