ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

ionic 2 beta.11 ion-silides options, still present in Ionic 2 RC4

Open betaengine opened this issue 10 years ago • 18 comments

open this page,First show the first page, and then jump to the second page But I set second pages for the initial,beta.10 is Available


version: 2.0.0-beta.11

<ion-slides [options]="opts">
      <ion-slide>
    <h1>Slide 1</h1>
  </ion-slide>
  <ion-slide>
    <h1>Slide 2</h1>
  </ion-slide>
  <ion-slide>
    <h1>Slide 3</h1>
  </ion-slide>
</ion-slides>

export class test implements OnInit{
opts:any;
    ngOnInit() {
this.opts = {initialSlide: 2, pager: true}
}

}

betaengine avatar Aug 08 '16 02:08 betaengine

Hello, thanks for opening an issue with us! Sorry, but i'm not understanding the issue fully. Would you mind creating a repo that i can use to test this issue? Thanks for using Ionic!

jgw96 avatar Aug 08 '16 17:08 jgw96

@jgw96

-------------------test.html----------------------------

<ion-content>
  <div>
    <ion-slides [options]="opts">
      <ion-slide *ngFor="let test of tests">{{test}}</ion-slide>
    </ion-slides>
  </div>
</ion-content>

-------------------test.ts----------------------------

@Component({
    templateUrl: 'build/pages/test/test.html',
})
export class TestPage implements OnInit{
    tests = [1,2,3];
    opts: any;
    constructor() {}
    ngOnInit() {
            this.opts = {initialSlide: 1}
    }

}


I have set {initialSlide: 1}.The initial index of second pages, but in version beta. 11 can see first display the first page, and then automatically jump to page second.In version beta.10,show second pages at once.

betaengine avatar Aug 09 '16 01:08 betaengine

I have that same issue with the { initialSlide = ...} option. After the page with the slides has loaded, you can see (for a short time) the first of all slides and then the desired 'initialSlide'.

I tried to work around that issue and implemented a slider.slideTo(initialSlide, 0, false) statement within the various page cycle events (ionViewLoaded, ionViewWillEnter, ionViewDidEnter). Only within the ionViewDidEnterevent the slideTo-statement works as expected and jumps to the 'initialSlide', but with the same tiny lag after showing the first of all slides. So no real workaround.

szerner avatar Aug 09 '16 06:08 szerner

still flashes first slide in rc0, before showing initialSlide: x

petermm avatar Oct 06 '16 20:10 petermm

There are few bugs with initialSlide option:

  1. Flickering of the view
  2. After init with initialSlide option, you can't call getActiveIndex(), error: ORIGINAL EXCEPTION: Cannot read property 'activeIndex' of undefined.

I believe this is caused because the slide is changing to another one and ionDidChange is called

    this.horizontalSliderOptions = {
      loop: false,
      pager: false,
      direction: "horizontal",
      initialSlide: 1
    }

  (ionDidChange)="onSlideChanged()"

  onSlideChanged(e) {
    let activeHorizontal = this.horizontalSlider.getActiveIndex()
 }

axelauvinen avatar Nov 03 '16 10:11 axelauvinen

This bug is still present in Ionic 2 RC2. Maybe you can change the title of the issue?

martin-eberle avatar Nov 11 '16 13:11 martin-eberle

And also in RC3 :-/

martin-eberle avatar Nov 23 '16 11:11 martin-eberle

Still present on RC4; the shown slider is always the default at index 0 and then switches to whatever was set as initialSlide.

I have mentioned on another issue ( which I believe to be a duplicate of this one, #9138 ) and I've provided a repository to reproduce the issue that can be found here.

AleFons avatar Dec 23 '16 13:12 AleFons

Has anyone tested this issue on RC5 ? I used a workaround on RC4 and it works but I'd rather have a stable solution...

ericdude4 avatar Jan 24 '17 16:01 ericdude4

@ericdude4 I'm using RC5 and while there are some slight differences in the implementation of ion-slides in it, it's working as intended. I believe the issue is now solved.

AleFons avatar Jan 24 '17 18:01 AleFons

Thanks @AleFons. I am going to close this then, but please let me know if anyone sees the problem with RC6 and I will reopen. :)

brandyscarney avatar Jan 24 '17 23:01 brandyscarney

Hey @ericdude4 can you post some example?

miguelmchavez avatar Feb 09 '17 14:02 miguelmchavez

@miguelmchavez would you like the solution that I found previously? Recently I have updated to Ionic 2 stable release and the issue was resolved, however, I would be more that happy to explain my fix.

ericdude4 avatar Feb 10 '17 08:02 ericdude4

yes @ericdude4 , i like the solution that you found previously! Please.

miguelmchavez avatar Feb 10 '17 14:02 miguelmchavez

@miguelmchavez This was my solution on RC4, so if you are using an older one, the line where the code is may be different:

  1. open node_modules > ionic-angular > components > slide > slide.js

  2. locate the following (approx. line 262)

setTimeout(function () {
     var swiper = new Swiper(_this.getNativeElement().children[0], options);
     _this.slider = swiper;
 }, 300);
  1. replace this code with:
setTimeout(function () {
     var swiper = new Swiper(_this.getNativeElement().children[0], options);
     _this.slider = swiper;
	
 });

ericdude4 avatar Feb 10 '17 15:02 ericdude4

@ericdude4 Great, can you post your final typescript page?

miguelmchavez avatar Feb 10 '17 17:02 miguelmchavez

@miguelmchavez the old typescript page you would have had with the initialSlide issue should work now. It will no longer flash the first slide before moving to the initialSlide.

ericdude4 avatar Feb 15 '17 07:02 ericdude4

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 04 '18 01:09 ionitron-bot[bot]