Wikiki / bulma-carousel

Display a carousel
MIT License
136 stars 99 forks source link

Carousel not functioning properly if it contains only one image #14

Closed nicholaskajoh closed 6 years ago

nicholaskajoh commented 6 years ago

If the carousel contains only one image, the image is not displayed and clicking any of the navigation buttons generates an error.

<div class='carousel carousel-animated carousel-animate-slide'>
  <div class='carousel-container'>
    <div class='carousel-item has-background is-active'>
      <img class="is-background" src="https://wikiki.github.io/images/merry-christmas.jpg" alt="" width="640" height="310" />
      <div class="title">Merry Christmas</div>
    </div>
  </div>
  <div class="carousel-navigation">
    <div class="carousel-nav-left">
      <i class="fa fa-chevron-left" aria-hidden="true"></i>
    </div>
    <div class="carousel-nav-right">
      <i class="fa fa-chevron-right" aria-hidden="true"></i>
    </div>
  </div>
</div>

The error generated from the code above if a navigation button is clicked.

Uncaught TypeError: Cannot read property 'classList' of null
    at a._slide (extension.js:180)
    at HTMLDivElement.nextControl.nextControl.addEventListener (extension.js:58)
_slide @ extension.js:180
nextControl.nextControl.addEventListener @ extension.js:58
Wikiki commented 6 years ago

Fixed