我有这样的 slider :
<ion-slides #promoSlider [options]="homeOptions" (change)="onPromoSlideChanged()" >
<ion-slide *ngFor="let promo of promos">
<img *ngIf="promo" src="{{promo.image}}" style="width:300px;height:300px;margin:auto;display:block" >
</ion-slide>
</ion-slides>
我已使用此选项通过自动播放保持幻灯片播放:
homeOptions = {
initialSlide: 0,
loop: true,
autoplay:2000
};
但问题是,当我滑动 slider 时,自动播放停止,并且 slider 不再滑动。即使我滑动 slider ,如何保持 slider 播放。我已经尝试过这段代码:
onPromoSlideChanged() {
alert('ABC');
this.promoSlider.options = this.homeOptions;
this.promoSlider.rapidUpdate();
//What should i do in this method?
};
当我滑动 slider 时,我需要什么事件来保持 slider 再次滑动(继续播放)?谢谢...
最佳答案
您可以在这里找到答案 => https://forum.ionicframework.com/t/how-to-keep-slides-auto-play-when-the-slides-is-swiped/54025/6
The official docs reference the component Swiper as the base of the ion-slides component, so the API should be the same as the one described in http://idangero.us/swiper/api/11.
You could use the option autoplayDisableOnInteraction to avoid disabling auto play after the user interaction.
Your options array should be:
homeOptions = { initialSlide: 0, loop: true, autoplay:2000, autoplayDisableOnInteraction: false };
Hope it helps.
关于ionic-framework - (Ionic 2) 滑动幻灯片时保持幻灯片自动播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37659502/