-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a pause button for Carousels #1146
Conversation
11da3d8
to
47a3cb9
Compare
577d087
to
05a2203
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel weird using the pause button and unpause on hover. IMHO, I would have done a pause button that prevent hover on carousel play/pause behavior
js/src/carousel.js
Outdated
this._element.nextElementSibling.classList.add('play') | ||
this._element.nextElementSibling.setAttribute('title', 'Play Carousel') | ||
this._element.nextElementSibling.querySelector('span.visually-hidden').innerHTML = 'Play Carousel' | ||
this._isPaused = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, this is dupe with following code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is mandatory in order to prevent side effects between the play/pause button VS the already existing 'pause on hover' option.
Without this line, if you set the carousel to pause using the button and hover it with your cursor then the carousel will stay on pause on mouseenter
and will restart to cycle on mouseleave
but it will be stuck on the current slide.
However it may be due to the bug I found on Bootstrap carousel but we will have to wait for their fix to check it.
I do not think that i's a good idea to block an option for users. In my opinion it's better to allow both and to make sure that it will not break is someone want to use both options. |
@@ -479,6 +479,22 @@ describe('Carousel', () => { | |||
}, 10) | |||
}) | |||
}) | |||
|
|||
it('should take care of element either passed as a CSS selector or DOM element (Play/Pause button)', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure to understand this test, shouldn't it return the Carousel itself since you call new Carousel
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed together, it's a basic test used in all components. I think we need to keep it as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two little points to clarify, but LGTM already.
js/tests/unit/carousel.spec.js
Outdated
const carouselEl = fixtureEl.querySelector('#myCarousel') | ||
const carousel = new Carousel(carouselEl) | ||
|
||
spyOn(carousel, 'pause').and.callThrough() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these .callthrough
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
const mouseOverEvent = createEvent('mouseover') | ||
carouselEl.dispatchEvent(mouseOverEvent) | ||
|
||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these setTimeout
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because of th promise.
fe7df32
to
455a5b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if the behavior is approved !
FYI approved by the a11y team. |
16001a7
to
caa8434
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't finished the review yet but here are some first comments.
16001a7
to
520a54b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding performance, I think it could be a bit better.
Just looked at it, but the example button seems to be not aligned with the carousel
js/src/carousel.js
Outdated
if (this._playPauseButton !== null && this._playPauseButton.classList.contains('pause')) { | ||
this._playPauseButton.classList.remove('pause') | ||
this._playPauseButton.classList.add('play') | ||
this._playPauseButton.setAttribute('title', this._playPauseButton.getAttribute(SELECTOR_CAROUSEL_PLAY_TEXT)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think we should have a default value in English I guess
js/tests/unit/carousel.spec.js
Outdated
' <div class="carousel-item">item 3</div>', | ||
' </div>', | ||
'</div>', | ||
'<button type="button" class="btn btn-icon btn-secondary pause" data-bs-control="play-button" data-bs-target="#myCarousel" data-bs-play-text="Play Carousel" data-bs-pause-text="Pause Carousel" title="Pause Carousel">', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should try with another text or language here ?
39043f5
to
fc3f65b
Compare
e401bfa
to
31e3fce
Compare
I agree with @louismaximepiton's comment |
@MewenLeHo There is an issue with JS tests probably linked to the remaining const buttonPlayPauselEl = fixtureEl.querySelector('[data-bs-control="play-button"]')
const buttonPlayPauselBySelector = new Carousel('[data-bs-control="play-button"]') I let you fix the tests and then I'll approve + merge 🚀 |
Bundlewatch needs to be updated as well |
c9354f9
to
2c06277
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Closes #1112