meliorence / meliorence/react-native-snap-carousel

activeSlideAlignment not updated immediately ?

Open
#869 1 comment 0 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?

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.