meliorence / meliorence/react-native-snap-carousel

onSnapToItem never gets called

Open
#541 11 comments 1 reaction 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

Using "react-native-snap-carousel": "3.7.5"
Testing on iOS

Here is my code

<Carousel
                    ref={(c) => { this._carousel = c; }}
                    vertical={true}
                    data={["1", "2", "3", "4", "5", "6", "7", "8"]}
                    renderItem={({ item, index }) =>

                        <TouchableOpacity
                            style={{ flex: 1, backgroundColor: "transparent" }}
                            onPress={() => { this._carousel.snapToItem(index) }}>
                            <Text
                                style={{
                                    height: 30,
                                    textAlignVertical: 'center',
                                    flex: 1,
                                    textAlign: 'center',
                                    fontSize: 16
                                }} key={"money" + item}>{item}</Text>
                        </TouchableOpacity>
                    }
                    onSnapToItem={(index) => {
                        console.log("Moved to=====> " + index)
                        alert(index)
                    }}
                    inactiveSlideOpacity={0.4}
                    inactiveSlideScale={0.9}
                    enableSnap={true}
                    removeClippedSubviews={false}
                    autoplay={false}
                    sliderHeight={80}
                    sliderWidth={90}
                    itemHeight={30}
                    itemWidth={90}
                />

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

Reproduce the iOS case using the shown Carousel configuration, then trace the snapToItem entry point and the onSnapToItem callback path. Confirm the cause by getting the callback to log and alert the selected index after an item is snapped.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.