You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Keyframe animations are a great way to add smooth transitions between the closed and shown states of <dialog> and <popover>. This approach has several advantages:
No need to provide a @starting-style.
No need to explicitly enable discrete animations.
Unlike transition, animation is supported by all major browsers for shown states; only the closed state animations are currently limited to Chromium-based browsers.
For the shown state, no additional work is needed as animations work out of the box. However, for the closed state, adding the display property to the out animation is required, as shown in this example:
.animate-slide-up-down {
/* motionOK */@media (prefers-reduced-motion: no-preference) {
animation: slide-out-down 0.5svar(--ease-3);
&:popover-open {
/* Built-in animation from Open Props */animation:var(--animation-slide-in-up);
}
}
}
@keyframes slide-out-down {
from {
display: block;
}
to {
transform:translateY(100%);
}
}
The same applies to fade animations:
.animate-fade-in-out {
opacity:0;
/* motionOK */@media (prefers-reduced-motion: no-preference) {
animation: fade-out 0.5svar(--ease-3) forwards;
&:popover-open {
/* Built-in animation from Open Props */animation:var(--animation-fade-in) forwards;
}
}
}
@keyframes fade-out {
from {
display: block;
opacity:1;
}
to {
opacity:0;
}
}
what's possible given the snippets i'm about to share
why you want to avoid changing the display property
transitions for popover and dialog in one snippet
here's the styles needed to transition both popover and dialog (transform property not included). not sure we'll want to provide this exactly, or use the individual snippets. worth talking about. also, nesting isnt used because there were nesting limitations when I authored it. but now, these limits are fixed, and it could be turned into 1 snippet.
all in all, i totally agree these styles should be included in normalize (or as imports) and we should switch away from the previous dialog work into a more flexible solution.
Keyframe animations are a great way to add smooth transitions between the closed and shown states of
<dialog>
and<popover>
. This approach has several advantages:@starting-style
.transition
,animation
is supported by all major browsers for shown states; only the closed state animations are currently limited to Chromium-based browsers.For the shown state, no additional work is needed as animations work out of the box. However, for the closed state, adding the
display
property to theout
animation is required, as shown in this example:The same applies to fade animations:
See this example on CodePen and click one of the cards to view the animations live:
https://codepen.io/mobalti/pen/EaYVJgr
Summary
To handle animations when dialogs and popovers are closed, we can either:
display
property to the keyframes (if there are no side effects).The text was updated successfully, but these errors were encountered: