Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
fix(display): One Image display
Browse files Browse the repository at this point in the history
  • Loading branch information
Wikiki committed Feb 22, 2018
1 parent 9cfea7f commit c1a667a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
16 changes: 16 additions & 0 deletions dist/bulma-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class Carousel {

this.previousControl = this.element.querySelector('.carousel-nav-left');
this.nextControl = this.element.querySelector('.carousel-nav-right');
if (this.items.length <= 1) {
const carouselContainer = this.element.querySelector('.carousel-container');
if (carouselContainer) {
carouselContainer.style.left = '0';
}
if (this.previousControl) {
this.previousControl.style.display = 'none';
}
if (this.nextControl) {
this.nextControl.style.display = 'none';
}
}

this._bindEvents();
this._initOrder();
Expand Down Expand Up @@ -89,6 +101,10 @@ class Carousel {
*/
_initOrder() {
const currentActiveItem = this.element.querySelector('.carousel-item.is-active');
if (!currentActiveItem) {
this.items[0].classList.add('is-active');
currentActiveItem = this.items[0];
}
const currentActiveItemPos = this.items.indexOf(currentActiveItem);
if (currentActiveItemPos) {
this.items.push(this.items.splice(0, currentActiveItemPos));
Expand Down
Loading

0 comments on commit c1a667a

Please sign in to comment.