Skip to content

Commit

Permalink
fix(carousel): init carousel properly by setting anim on progress ind…
Browse files Browse the repository at this point in the history
…icator (#2204)

Co-authored-by: Julien Déramond <julien.deramond@orange.com>
  • Loading branch information
louismaximepiton and julien-deramond authored Aug 24, 2023
1 parent 851a0e3 commit 52c6b12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/src/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ class Carousel extends BaseComponent {

if (this._config.ride === CLASS_NAME_CAROUSEL) {
this.cycle()
} else if (this._indicatorsElement) { // Boosted mod: set the animation properly on progress indicator
this._element.classList.add(CLASS_NAME_PAUSED)
}
// End mod
}

// Getters
Expand Down
9 changes: 9 additions & 0 deletions js/tests/unit/carousel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ describe('Carousel', () => {
expect(carousel._interval).toBeNull()
})

// Boosted mod
it('should add class if `ride`!==`carousel`', () => {
fixtureEl.innerHTML = '<div id="myCarousel" class="carousel slide" data-bs-ride="true"><ol class="carousel-indicators"></ol></div>'

const carousel = new Carousel('#myCarousel')
expect(carousel._element.classList).toContain('is-paused')
})
// End mod

it('should go to next item if right arrow key is pressed', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = [
Expand Down

0 comments on commit 52c6b12

Please sign in to comment.