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

Accordion Example: Add animation on expand/collapse #843

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions examples/accordion/css/accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@
.Accordion-panel {
margin: 0;
padding: 1em 1.5em;
overflow: hidden;
transition: all 500ms;
}

/* For Edge bug https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4806035/ */
.Accordion-panel[hidden] {
display: none;
display: block;
height: 0;
padding-top: 0;
padding-bottom: 0;
border-top: 0;
visibility: hidden;
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting visibility to hidden here prevents the majority of the animation from happening since it causes the element to have no height, which in turn means that the height cannot transition to 0. The end result is that only the padding is actually transitioning.

}

fieldset {
Expand All @@ -80,3 +86,10 @@ input {
font-size: inherit;
padding: .3em .5em;
}

/* Applies styles when Reduced Motion is enabled */
@media screen and (prefers-reduced-motion: reduce) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

.Accordion-panel {
transition: none;
}
}