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

feat: Support CSS transitions in RAC #7488

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

devongovett
Copy link
Member

Fixes #6225, closes #5627

For discussion. This adds support for CSS transitions to RAC for entry and exit animations, in addition to the existing support for keyframe animations. Transitions have the benefit that they are interruptible. I noticed in the ActionBar PR that if you clicked fast enough you could see it "jump". That's because when a keyframe animation is interrupted, it jumps to the end, and then the next animation starts. With CSS transitions, the next animation continues from where the previous one left off instead, avoiding this problem.

Currently there is no API change needed for this:

data-entering – waits for keyframe animations to complete, but does not wait for css transitions. For CSS transitions, the starting styles can be applied here, and after one frame, they are removed so that the transition to the default style occurs.
data-exiting – now waits for css transitions as well.

I'm not sure if this is confusing or not, or whether we should introduce another data attribute instead.

isEntering: 250,
transition: '[opacity, translate]',
transitionDuration: {
default: 250,
Copy link
Member Author

@devongovett devongovett Dec 6, 2024

Choose a reason for hiding this comment

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

A bit weird that this is not symmetric with isExiting. isEntering won't work because it is only applied for a single frame. With CSS transitions, isEntering is more like "starting style".

@rspbot
Copy link

rspbot commented Dec 6, 2024

@rspbot
Copy link

rspbot commented Dec 17, 2024

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

I think I like sticking with is entering and is exiting, that's pretty common language around this.

That it waits now for the transitions seems fine on the surface. I'm having trouble coming up with cases where people wouldn't want this behavior.

@devongovett
Copy link
Member Author

I think I like sticking with is entering and is exiting, that's pretty common language around this.

The potential confusion is that it does not wait for transitions in the entering state. The entering state acts as the starting state of the transition, then it is removed causing the transition to the default state. So while the transition state is happening (I would call that entering), isEntering is actually false.

@snowystinger
Copy link
Member

Ah, I see. I got hit by the confusion.
The mental model I was thinking of was https://reactcommunity.org/react-transition-group/css-transition

It doesn't look like we lose the ability to have asymmetrical animations? so I'm ok with it, I think we'll just need to document it much like CSSTransition did and explain what the base/to states are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants