Skip to content

Commit

Permalink
feat #1112 (carousel pause button): add accessibility attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
MewenLeHo authored and julien-deramond committed Apr 19, 2022
1 parent d1b89b4 commit ae4fc28
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/src/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ class Carousel extends BaseComponent {
}
// End mod

// Boosted mod: if a play-pause button is present, reset the button to pause on mouseleave
if (this._element.nextElementSibling.hasAttribute('data-bs-control') && this._element.nextElementSibling.classList.contains('play')) {
this._element.nextElementSibling.classList.toggle('play')
this._element.nextElementSibling.classList.toggle('pause')
}
// End mod

if (!event) {
this._stayPaused = false
}
Expand Down Expand Up @@ -509,10 +516,14 @@ class Carousel extends BaseComponent {
carouselToPause.pause()
pauseButton.classList.toggle('pause')
pauseButton.classList.toggle('play')
pauseButton.setAttribute('title', 'Play Carousel')
pauseButton.setAttribute('aria-label', 'Play Carousel')
} else {
carouselToPause.cycle()
pauseButton.classList.toggle('pause')
pauseButton.classList.toggle('play')
pauseButton.setAttribute('title', 'Pause Carousel')
pauseButton.setAttribute('aria-label', 'Pause Carousel')
}
}
// End mod
Expand Down

0 comments on commit ae4fc28

Please sign in to comment.