leecade / leecade/react-native-swiper

Loop={true} + initialIndex leads to brief off by one error flicker

Open
#1,003 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐛bug 🔎investigate component: ViewPager help wanted
Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

Which OS ?

iOS

Version

1.6

  • react-native-swiper v1.6
  • react-native v0.59.8
Expected behaviour

I was debugging an issue where setting the index param briefly showed the wrong data (off by one earlier) for a brief second before a redraw happened.

In debugging, this seems to be related to the loop={true} behavior (the default), since eliminating looping causes the offset to be calculated correctly and no flicker.

I'm guessing the implementation has some kind of 'extra' item at the front to handle the left-swipe when looping, and the initialOffset is not accounting for this?

Actual behaviour

Setting index causes it to start drawing on the correct position without a flicker.

Steps to reproduce
  1. Create a Swiper with multiple items, and loop={true}
  2. Set the initial index.
  3. Observe that it is briefly off by one before correcting itself.

Contributor guide

No contributing guide indexed for this repository

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 issue in a React Native Swiper using loop={true} and an initial index, then inspect the component's initial index and loop-offset handling. Done means the configured slide is shown immediately without a transient off-by-one flicker; no specific source file or test is named in the issue.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.