ionic-team / ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
127 stars 85 forks source link

Slides: The ionSlideDidChange event is not fired after ion-slides is initialized #83

Open ionitron-bot[bot] opened 6 years ago

ionitron-bot[bot] commented 6 years ago

Ionic version: [ ] 1.x [x] 2.x [x] 3.x

I'm submitting a ... [x] bug report [x] feature request [] support request

Current behavior: The ionSlideDidChange event is not fired after ion-slides is initialized and @Input initialSlide is not set or equals to 0.

Expected behavior: The ionSlideDidChange event is always triggered after ion-slides is set to it's initial position.

OR

The new event like ionSlideAfterInit is introduced so it will be possible to trace the position of the slider after it loads like:

<ion-slides (ionSlideAfterInit)="ionSlideAfterInit($event)">
ionSlideAfterInit(slides) {
    let slidesIndex = slides.getActiveIndex();
    ...
}

Steps to reproduce: Check out the console logs of this PLUNKER

Related code: Most probably it's here: https://github.com/ionic-team/ionic/blob/master/src/components/slides/swiper/swiper.ts#L823

Other information: We need this functionality to show some data that's related to the current slide outside of the slider.

Our current approach is to access slides by @ViewChild(Slides) slides and call slides.getActiveIndex() on both ionSlideReachStart and ionSlideDidChange

yet we are searching for a cleaner solution

nyoumi commented 5 years ago

we are waiting the cleaner solution!!!

nawwa commented 5 years ago

Your current approach is not working, ionSlideReachStart and ionSlideDidChange are not triggered.