leecade / react-native-swiper

The best Swiper component for React Native.
MIT License
10.4k stars 2.34k forks source link

When first loaded, the swiper displays last page with first dot index. #635

Open vellengs opened 6 years ago

vellengs commented 6 years ago

Which OS ?

iphone 7 plus, ios 10.2

Version

Which versions are you using:

Expected behaviour

When first loaded, the swiper should display first page with first dot index.

Actual behaviour

When first loaded, the swiper displays last page with first dot index.

How to reproduce it>

To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.

Steps to reproduce

  1. run example swiper
Chersquwn commented 6 years ago

same issue here

Tennen commented 6 years ago

@vellengs I had the same issue and I fix it in my fork, maybe you can have a test if it really works

controversialUser commented 6 years ago

@Tennen i edited these file and now it works great , thanks man https://github.com/Tennen/react-native-swiper/commit/fcef2fbd427f8e9c62dfa8c3b7ea071f02063da3

stage88 commented 6 years ago

I have the exact same problem, I've tried the fix @Tennen implemented and it fixes my issues.

I've also made a small fix to account for scenarios where the swiper width is not full screen width, line 274:

    // since defaultProps of index is 0
    // when nextProps didnt contain index, initial offset would be { 0, 0 }
    initState.offset[initState.dir] = initState.dir === 'y'
      ? initState.height * initState.index
      : initState.width * initState.index;

    // fix render last page first when loop = true
    if (props.loop) {
      initState.offset[initState.dir] = initState.dir === 'y'
        ? initState.height * (initState.index + 1)
        : initState.width * (initState.index + 1);
    }
HeeTing commented 6 years ago

@stage88 your sources has a problem, when set loop is true the Swiper just can swiper severl times

super-ax commented 6 years ago

ios@Tennen这样改了会引发另一个问题,图片滑到最后就滑不动了,还会导致图片无法轮播了

Tennen commented 6 years ago

@super-ax 我目前用自己的这个版本没有出现这个问题..能告诉我是什么情况下出现的吗,我好测试下看看.

super-ax commented 6 years ago

@Tennen 首页轮播图滑动到最后一张,不能再向后滑动,点击图片进入详情页,然后返回,图片就不自动轮播了

Tennen commented 6 years ago

@super-ax 我试了一下autoplay是好的..有没有demo或者代码看看呀?

super-ax commented 6 years ago

@Tennen react-native-swiper\src\index.js

index.zip

Tennen commented 6 years ago

@super-ax 你的initState的方式跟我不一样呀,这不是按照我的改的吧..

super-ax commented 6 years ago

Desktop.zip @Tennen 麻烦你了,昨天应该是我把改的代码回滚了,今天重新改了一遍,还有问题

SamiChab commented 6 years ago

Any updates on this? How can I solve this problem?