Daemonite / material

Material Design for Bootstrap 4
http://daemonite.github.io/material/
MIT License
3.2k stars 725 forks source link

Carousel not auto sliding #281

Closed mitchn5 closed 1 year ago

mitchn5 commented 2 years ago

Upon grabbing the code example from https://daemonite.github.io/material/docs/4.0/components/carousel/ the auto sliding that was shown no longer shows up in my app. My code is below. Our framework is Angular/material-io.

<div class="row">
  <div *ngIf="promoUrl !== null" id="carousel" class="carousel slide container" data-ride="carousel">
    <div class="carousel-inner">
      <div class="carousel-item active">
        <img [src]="promoUrl" (error)="promoUrl = defaultPromo" [ngClass]="[isWeb || isIpad ? 'promoWeb' : '']" class="promo" alt="">
      </div>
      <div class="carousel-item" *ngFor="let promo of promos;">
        <img [src]="promo" (error)="onImgError($event)" [ngClass]="[isWeb || isIpad ? 'promoWeb' : '']" class="promo" alt="">
      </div>
    </div>
    <a class="carousel-control-prev" href="#carousel" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#carousel" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
  <div *ngIf="promoUrl === null" [ngClass]="[isWeb ? 'center' : '']" class="container">
    <img [src]="defaultPromo" class="promo" alt=""/>
  </div>
</div>
mitchn5 commented 2 years ago

I have added data-ride="carousel" or data-wrap="false" and those aren't reflected. The only one that seems to work in html is data-interval.

djibe commented 2 years ago

Hi, well it works in my fork (https://djibe.github.io/material/docs/4.6/components/carousel/)

mitchn5 commented 2 years ago

Hi @djibe, I've tried your carousel example with no luck as well. Is it possible I'm missing something outside of just the html? It's strange that certain options work while others don't.

djibe commented 2 years ago

Apart from bootstrap.bundle.min.js, you just need data-attributes or control with JS. Does your console show an error loading scripts ?

mitchn5 commented 2 years ago

Yea I've included a script tag for bootstrap in index.html, the carousel will only cycle after user clicks next/prev then clicks away from carousel.

mitchn5 commented 1 year ago

Hi guys, I added this to my component.ts page for this html and it fixed my issue.

$(document).ready(function() { // @ts-ignore $('.carousel').carousel({ interval: 5000, ride: 'carousel', touch: true }); });