leecade / leecade/react-native-swiper

Setting index property scrolls to wrong offset when using flexbox layout

Open
#651 1 comment 2 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

Which OS ?

iOS 11

Version

react-native-swiper v1.5.13

How to reproduce it

Here is the view that reproduces the problem:

<View style={{backgroundColor: 'white', flex: 1, alignItems: 'center', justifyContent: 'center',}}>
  <View style={{width: 300, height: 300,}}>
    <Swiper index={1} loop={false}>
      <View style={{backgroundColor: 'blue', flex: 1,}} />
      <View style={{backgroundColor: 'orange', flex: 1,}} />
      <View style={{backgroundColor: 'black', flex: 1,}} />
    </Swiper>
  </View>
</View>

Since the Swiper is using flex: 1 to render at a size that's smaller than the window, setting the index={1} scrolls the scroll view too far.

Expected behaviour
screen shot 2017-11-09 at 6 12 45 pm
Actual behaviour
screen shot 2017-11-09 at 6 12 54 pm

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

Start by running the provided iOS 11 reproduction with react-native-swiper v1.5.13, focusing on the Swiper's initial index inside the smaller flexbox container. Trace how the initial scroll offset is calculated and verify that index={1} lands on the second slide without scrolling beyond the container's bounds.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.