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

Entry and Exit Animations #829

Closed
1 task done
josepharhar opened this issue Mar 29, 2023 · 14 comments
Closed
1 task done

Entry and Exit Animations #829

josepharhar opened this issue Mar 29, 2023 · 14 comments

Comments

@josepharhar
Copy link

こんにちは TAG-さん!

I'm requesting a TAG review of Entry and Exit Animations.
I am using one TAG issue for these features because they are used together to accomplish an important use case.

Entry and Exit Animations is a set of CSS features which makes it possible to animate elements to and from display:none, and to animate elements entering and leaving the top layer, like <dialog> and elements with the popover attribute.

The CSS features include:

  1. CSS transitions for discrete properties, which allows the transition property to animate discrete properties like display.
    (formerly Transitions on specified discrete properties #825)
    CSSWG issue: [css-transitions-2] Start transitions on discrete animation types w3c/csswg-drafts#4441
  2. CSS transitions and animations for the display property
    (formerly Display and content-visibility animations #824)
    CSSWG issue: [css-display] Why is display listed as not animatable instead of animation type: discrete? w3c/csswg-drafts#6429
  3. CSS @initial rule, which allows animations to start from display:none.
    CSSWG issue: [selectors-4] Add syntax to establish before-change style for css-transitions on new elements. w3c/csswg-drafts#8174
  4. CSS overlay property, which allows animations on elements entering or leaving the top layer.
    CSSWG issue: [css-animations-2, css-transitions-2] Entry and exit animations for top-layer elements w3c/csswg-drafts#8189

Further details:

  • I have reviewed the TAG's Web Platform Design Principles
  • Relevant time constraints or deadlines: We are trying to ship this in Chrome 114 which branches on April 20th and goes to stable on May 30th
  • The group where the work on this specification is currently being done: CSSWG
  • The group where standardization of this work is intended to be done (if current group is a community group or other incubation venue): CSSWG
  • Major unresolved issues with or opposition to this specification: none
  • This work is being funded by: Google

We'd prefer the TAG provide feedback as (please delete all but the desired option):

💬 leave review feedback as a comment in this issue and @-notify [github usernames]

@LeaVerou
Copy link
Member

Hi @josepharhar,

@ylafon and I spent quite some time during our Tokyo F2F looking at the various issues, and the explainer.

Overall we like the direction that this is going.
Designing a solution to this problem as small independently useful improvements on existing features that can together be leveraged to solve the problem is a good practice.

We also like that existing transition syntax could be leveraged to do the right thing, rather than introducing new syntax.

We see discussion went from :initial to @initial due to specificity issues (?), but we could not find a definition of what @initial is/does. We are also concerned that the name will be confusing for authors, as initial is an existing, unrelated concept in CSS (initial values).

Making transitions to display: none inert seems preferable, though it is unfortunate the inert property was resolved against, and thus authors can not opt out or use this behavior for other use cases.

For some of these issues (e.g. 6429) there seemed to be still active discussion after any resolutions, making us wonder if shipping this might be a little premature.

@LeaVerou LeaVerou added Progress: pending external feedback The TAG is waiting on response to comments/questions asked by the TAG during the review and removed Progress: in progress labels Apr 19, 2023
@josepharhar
Copy link
Author

we could not find a definition of what @initial is/does

Here is a spec PR which should make a clear definition: w3c/csswg-drafts#8876

We are also concerned that the name will be confusing for authors, as initial is an existing, unrelated concept in CSS (initial values).

It was changed to @starting-style based on additional discussion

For some of these issues (e.g. 6429) there seemed to be still active discussion after any resolutions, making us wonder if shipping this might be a little premature.

We just resolved on additional behavior details on w3c/csswg-drafts#6429

@lilles
Copy link

lilles commented Jun 22, 2023

The PR for @starting-style is now in css-transitions-2:

https://drafts.csswg.org/css-transitions-2/#defining-before-change-style-the-starting-style-rule

@nt1m
Copy link

nt1m commented Jun 22, 2023

I think one question I'd be interested in seeing answered regarding this new feature is why:

dialog {
  @starting-style {
     opacity: 0;
  }
  transition: opacity 0.4s;
}

is preferable over:

@keyframes fade-in {
  0% { opacity: 0 }
}
dialog {
  animation: fade-in 0.4s;
}

They both work and achieve the same use case, and the new syntax isn't that much shorter.

@flackr
Copy link

flackr commented Jun 23, 2023

For the simple use case they indeed both work, however developers often prefer transitions for their ergonomic simplicity in dealing with arbitrary subsequent changes. For example, with the fade animation:

@keyframes fade-in {
  0% { opacity: 0 }
}
dialog {
  animation: fade-in 0.4s;
}
  1. Any subsequent changes to the opacity while it is animating in take effect immediately, even if transition: opacity 0.4s; is set.
  2. If you hide the dialog while it is still progressing through the showing animation, a transition will implicitly reverse from the point it is currently at - and at the appropriate speed per css-transitions-3.1

These behaviors are often desirable and much harder to get right with animations. For example, I put together a demo showing the difference between naively using animations vs transitions for entry and/or exit:
https://jsbin.com/coxewex/edit?html,css,output
Note: Move the mouse out before the animation finishes to see the significant differences.

You can see with an animation in and transition out the transition is completely skipped if the animation hasn't finished yet, and if you use an animation in both direction then it's not easy to prevent it from playing from the shown state.

@nt1m
Copy link

nt1m commented Jun 24, 2023

This makes sense, thanks. I guess the other question I have now that we're talking about @Keyframes is how both features interact together. What happens if someone uses animations and @starting-style on the same element? or if they set animations in @starting-style.

@LeaVerou
Copy link
Member

This makes sense, thanks. I guess the other question I have now that we're talking about @Keyframes is how both features interact together. What happens if someone uses animations and @starting-style on the same element? or if they set animations in @starting-style.

The same as any other time that transitions and animations are running at the same time?

@nt1m
Copy link

nt1m commented Jun 24, 2023

Ah right, need for think more before I write 😅. The reason this popped in my mind was that I could see sites using both @starting-style and @Keyframes on the same element (not necessarily as intended).

@torgo torgo added this to the 2023-12-18-week milestone Dec 17, 2023
@LeaVerou LeaVerou added Progress: in progress and removed Progress: pending external feedback The TAG is waiting on response to comments/questions asked by the TAG during the review labels Dec 18, 2023
@LeaVerou LeaVerou self-assigned this Dec 18, 2023
@LeaVerou
Copy link
Member

Hi there, quick question as we do some end-of-year housekeeping. We notice the title of this issue is "Entry and Exit Animations", but right now CSS only includes entry animations, and exit animations have been contentious. Is this meant as a design review for both, or just about @starting-style?

@nt1m
Copy link

nt1m commented Dec 18, 2023

I think the exit bits are somewhat covered by the discrete transition stuff.

@LeaVerou
Copy link
Member

I think the exit bits are somewhat covered by the discrete transition stuff.

Not sure I follow, could you please elaborate?

@nt1m
Copy link

nt1m commented Dec 18, 2023

This was about being able to do exit animations for display: none for most part (so from display: block to display: none), since it's the most common case for popovers. AFAIK, transition: display 1s allow-discrete, opacity 0.1s covers this case. I don't think exit animations for element removal was ever a goal of this specific issue.

@josepharhar
Copy link
Author

Exit animations can be done with transition-behavior:allow-discrete as Tim said. Here is a minimal example: https://jsfiddle.net/jarhar/cyugx34v/4/
The overlay property also allows these elements to stay in the top layer during their exit animation.

These have both been specced, have tests, and have been shipped in chrome:
web-platform-tests/interop#580
web-platform-tests/interop#581

@plinss plinss removed this from the 2024-02-19-week milestone Mar 11, 2024
@torgo torgo added this to the 2024-03-18-week milestone Mar 17, 2024
@plinss plinss removed this from the 2024-03-18-week milestone Mar 25, 2024
@plinss plinss added this to the 2024-05-13-week:b milestone May 13, 2024
@plinss plinss removed this from the 2024-05-20-week:b milestone May 27, 2024
@plinss plinss added this to the 2024-06-24-week:e milestone Jun 24, 2024
@torgo torgo modified the milestones: 2024-08-05-week, 2024-08-26-week Aug 8, 2024
@torgo torgo added Progress: propose closing we think it should be closed but are waiting on some feedback or consensus and removed Progress: in progress labels Sep 9, 2024
@torgo
Copy link
Member

torgo commented Sep 12, 2024

As discussed in TAG calls this week: We see that the browsers have agreed to focus on implementing these features as part of Interop 2024. While some of the details may still not be optimal, we don't think there are any architectural concerns, and we think the CSSWG is the right place to continue refining the design, if necessary. Thank you for bringing us this review!

@torgo torgo closed this as completed Sep 12, 2024
@torgo torgo added Progress: review complete Resolution: satisfied The TAG is satisfied with this design and removed Progress: propose closing we think it should be closed but are waiting on some feedback or consensus labels Sep 12, 2024
@torgo torgo removed this from the 2024-09-09-week milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants