meliorence / meliorence/react-native-snap-carousel

Carousel slide animations not working when inside a Animated.View

Open
#543 5 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

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>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied PanGestureHandler, Animated.View, and Carousel example on Android with pointerEvents set to box-none, then compare it with iOS behavior. Confirm whether the translateY and carousel animations can run together without the production crash; use the reported React Native and react-native-snap-carousel versions when testing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.