ionic-framework - (Ionic 2) 滑动幻灯片时保持幻灯片自动播放

标签 ionic-framework angular ionic2 swiper.js

我有这样的 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/

相关文章:

angular - 如何在angular2中每2分钟调用一次函数?

angular - map 不是函数 (Rxjs) 虽然导入

angular - ionic 网络安全配置

ios - Apple Store - 拒绝使用 UIWebView 的新应用;这会影响我现有的应用程序和 future 的版本吗?

php - Laravel passport登录系统,如何登录用户并获取access_token和refresh token?

Angular + Material - 如何在表格中添加自定义列(Mat-Table)

ionic-framework - 如何在 ionic 中隐藏标题栏?

html - 如何在 Angular 中显示两个连续的空间?

angular - Tslint - 类型简单推断 - 为什么在此处包含类型是不好的做法?

Angular 4 - 属性值未在 View 中更新