Skip to content

Carousel crossfade > Prevent the background to be shown when transitioning#27529

Merged
XhmikosR merged 2 commits intotwbs:v4-devfrom
MartijnCuppens:better-carousel-crossfade
Oct 30, 2018
Merged

Carousel crossfade > Prevent the background to be shown when transitioning#27529
XhmikosR merged 2 commits intotwbs:v4-devfrom
MartijnCuppens:better-carousel-crossfade

Conversation

@MartijnCuppens
Copy link
Copy Markdown
Member

When the carousel is transitioning, the background is shown through the images. This PR prevents this from happening by disabling the transition of the carousel item that is fading out and raising the z-index of the carousel item that is fading in. I also needed to raise the z-index of the carousel controls, the indicators had a z-index which was high enough.

I had to add the transition-delay to the getTransitionDurationFromElement function to prevent the classes to be removed too soon. Not sure if we should rename this function to make this clear or not.

Issue:
https://getbootstrap.com/docs/4.1/components/carousel/#crossfade

Demo new carousel:
https://deploy-preview-27529--twbs-bootstrap4.netlify.com/docs/4.1/components/carousel/#crossfade

Copy link
Copy Markdown
Contributor

@midzer midzer left a comment

Choose a reason for hiding this comment

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

I can clearly experience an improved crossfade on your demo. Awesome, will definetly use it in some of my projects soonish. JS code looks flawlessly on first glance and CSS appears tidy, too.

@MartijnCuppens
Copy link
Copy Markdown
Member Author

Thanks @midzer!

Copy link
Copy Markdown
Member

@Johann-S Johann-S left a comment

Choose a reason for hiding this comment

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

Works fine to me 👍

Can you add a unit test, which show we handle transition-delay too please ?

Comment thread js/src/util.js Outdated
Comment thread scss/_variables.scss Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this is only added so that we get the value in JS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

And to prevent the transition of the carousel item that is "fading out". We need this because otherwise the classes are removed immediately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just wondering if we could use the transition shorthand, that's why I'm asking.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can use the shorthand to combine these lines indeed:
https://github.com/twbs/bootstrap/blob/9b3c66258997c10f8bdb1ea521ed64e3775da39d/scss/_carousel.scss#L100-L101
I'll look into that

But I'll still need the $carousel-transition-duration option as a separate variable.

@MartijnCuppens MartijnCuppens force-pushed the better-carousel-crossfade branch from 29aca1f to 168c422 Compare October 29, 2018 20:12
@XhmikosR XhmikosR merged commit 5aed968 into twbs:v4-dev Oct 30, 2018
@mdo mdo mentioned this pull request Oct 30, 2018
@MartijnCuppens MartijnCuppens deleted the better-carousel-crossfade branch October 30, 2018 07:08
@XhmikosR
Copy link
Copy Markdown
Member

XhmikosR commented Oct 30, 2018

@MartijnCuppens so this seems to break on IE 10.

See for example https://travis-ci.org/twbs/bootstrap/jobs/448234618#L633

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants