phil-r / react-native-looped-carousel

:carousel_horse: Looped carousel for React Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

animateToPage and _animatePreviousPage not working

MSSPL-PiyaleeMaiti opened this issue ยท comments

_animatePreviousPage()
animateToPage(0)

above two methods are not working properly when isLooped = {false} if I set this to isLooped = {true} then it's works fine.

But I need isLooped = {false} and also need that method also. How can I solve my problem?

@phil-r Hi, is there any update on this issue?

Hey ๐Ÿ‘‹
You can try out this example: https://snack.expo.io/@phil/carousel-animate-to-page-example

The key parts are:
ref={ref => (this.carousel = ref)} in Carousel props
onAnimate={i => this.carousel.animateToPage(i)} in Page props

@phil-r I already used this method animateToPage(i) but it's not working only for 0 index page. When I want to go to 0 index page then it shows the last page instead of 0 index page. This issue is happen when isLooped = {false} but when I set to isLooped = {true} then it's working properly. But I want this method is works with isLooped = {false} , how it could be possible please suggest me.
My code is below:

changeCurrentPage = () => {
    this._carousel.animateToPage(0);
    // this._carousel._animatePreviousPage();
  }

<Carousel
          delay             = {2000}
          style             = {this.state.size}
          autoplay          = {false}
          isLooped          = {false}
          pageInfo          = {false}
          bullets           = {true}
          bulletStyle       = {{backgroundColor:'#BFBFBF', borderWidth:0}}
          chosenBulletStyle = {{backgroundColor:'#717171', borderWidth:0}}
          onAnimateNextPage = {(p) => console.log(p)}
          currentPage       = {this.state.currentPageNo}
          ref               = {(ref) => { this._carousel = ref; }}>
          <PageOne
          />
          <PageTwo
            changeCurrentPage          = {this.changeCurrentPage}
          />
          <PageThree
            changeCurrentPage = {this.changeCurrentPage}
          />
 </Carousel>

@MSSPL-PiyaleeMaiti make sure you're on 0.1.12 version

Yeah, looks like there was a bug in versions 0.1.11 and below.

Here is another example based on your code: https://snack.expo.io/SyNuF6Mk7

@phil-r thanks, I upgrade the version and its working fine. But I have a problem now about currentPage props. This props now not working in this updated version. Its always show the first page but bullet show currentPage number. How could I fix please suggest.

@MSSPL-PiyaleeMaiti Oops ๐Ÿ˜ณ I know where the bug is, I'll try to fix it this evening!

@phil-r ok thanks, I will be waiting for your reply.

@MSSPL-PiyaleeMaiti can you check 0.1.13, issue should be fixed ๐ŸŽ‰

@phil-r I need to upgrade the package again?

Thanks, @phil-r, now it's working properly. ๐Ÿ˜Š

Great! Thanks for creating an issue!

@phil-r this._carousel.animateToPage(0) this function is not working in iPhone6plus and iPhone7(real device).
In a real device, it's working in debug mode but when we build in adhoc then in a real device it's not working but in the simulator, it's working fine.

Please give us a solution as soon as possible, we need it urgently, we are develope this in the live project, so it's urgent.

@phil-r this._carousel.animateToPage(0) this function is not working in iPhone6plus and iPhone7(real device), when carousel page content have in between ScrollView, and the function is calling from ScrollView content, so is it not working from ScrollView?

@phil-r can you segguest any solution for iPhone6plus issue.
Below link for details isuue.
#228