Skip to content
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

Do not call next when the carousel or the parent isn't visible #23524

Merged
merged 3 commits into from
Aug 17, 2017

Conversation

Johann-S
Copy link
Member

@Johann-S Johann-S commented Aug 17, 2017

  • Unit test to be sure the carousel don't cycle when we cannot see it
  • Unit test to be sure the carousel don't cycle when is parent isn't visible

Work in progress...

Close : #23523

if (!document.hidden) {
// or the carousel or it's parent isn't visible
if (!document.hidden &&
($(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure those 2 checks aren't identical?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the first one just check if the parent or the carousel don't have display: none;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For more informations and precise explanations (with a better English 😆) : https://api.jquery.com/hidden-selector/

@XhmikosR
Copy link
Member

So we just need a test with both cases and we are all set. Thanks for the fast patch!

@Johann-S
Copy link
Member Author

I added the two unit tests so @XhmikosR if you're available for a quick code review 😄

setTimeout(function () {
assert.ok($firstItem.hasClass('active'))
$carousel.bootstrapCarousel('dispose')
$parent.attr('style', 'visibility: hidden;')
Copy link
Member

@XhmikosR XhmikosR Aug 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets visibility:hidden but doesn't remove display:none, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It remove the display: none; because we set the attribute value no matter what we had before that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, looks good to me then. If you can't think of anything else, please merge :)

@Johann-S Johann-S merged commit 58994a1 into v4-dev Aug 17, 2017
@Johann-S Johann-S deleted the v4-carousel-visibility branch August 17, 2017 16:48
@mdo mdo mentioned this pull request Aug 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants