Slider Issue when navigating back to the slider page

Hey Everyone!

I have a page with several sliders. Everything is working fine until I navigate to a different page. Post some few things on the server and then come back to the slider page.

All my sliders end up half-way, here’s a picture

image

This bug is not happening in ionic serve but only when I have build for my android phone.

I have tried to used a lifecycle hook and force the view to go to the first slide using slideTo(0, 0, false); but this is no longer working. (It was working before RC5).

Here’s the code in HTML

<ion-slides #mySlider>
  ...
</ion-slides>

Code in TS

@ViewChild('mySlider') slider: Slides;
...
ionViewWillEnter() {
    this.slider.slideTo(0, 5, false);
}

Anyone has faced this? How did you solve it?

If I turn the phone 90 degress (on landscape mode) and then come back on portrait mode, all the sliders get back into place.

1 Like

Hello @DeeM52 . Did you find a solution to this?
I am having a similar issues where only part of the active slide is displayed alongside part of the next or prev slide .
It seems to be random.
May be related to the use of *ngFor?

1 Like

did any of you find the solution to this? while navigating back the ion-slider autoplay don’t work.

1 Like

I also have this problem with ionic 5. Was working well in ionic 4

sorry for late reply, i did make it work in ionic 5 all you have to do is stop autoplay when you about to leave the page with ion-sliders.

ionViewWillLeave(){
    this.slider.stopAutoplay();
  }

ionViewDidEnter() {
    this.slider.startAutoplay();
  }

I found a simple way to fix this

public ionViewWillEnter(){
    this.slides.update();
}