meliorence / meliorence/react-native-snap-carousel
activeSlideAlignment not updated immediately ?
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?
question
so, i have a case where i need to dynamically change activeSlideAlignment for the carousel, while it work, but the carousel didn't actively recognized the changed activeSlideAlignment on the fly, it need to finish the previous activeSlideAlignment first, then move immediately to the changed activeSlideAlignment, for example, it goes to "start" first, then immediately blink to the changed activeSlideAlignment "end"
the transition feels jaring and jerky, is this intended behaviour, or is there something i need to do to make it smooth ?, for context, i change the activeSlideAlignment based on index, thus i also use onBeforeSnapToItem to check the index, setState, then check the state index, then change the activeSlideAlignment on props
code example
<Carousel
ref={(c) => { this._carousel = c; }}
data={this.props.data}
renderItem={this.smallCardView}
sliderWidth={sliderWidth }
itemWidth={itemWidth}
enableSnap={true}
inactiveSlideOpacity={1}
inactiveSlideScale={0.95}
onBeforeSnapToItem={(index) => this.setState({ index: index })}
activeSlideAlignment={this.props.data.length > 1 ? (this.state.index=== 1 ? 'center' : 'start') : 'center'}
/>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how Carousel handles the activeSlideAlignment prop during onBeforeSnapToItem and subsequent state updates. Reproduce the example with alignment changing by index, then determine whether the observed transition is intended or whether the prop update should take effect during the current snap.
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