Skip to content

Add "exitBeforeEnter" prop to useTransition #1064

Closed
@xzilja

Description

@xzilja

🚀 Feature Proposal

Add exitBeforeEnter property to useTransition hook. This property would be an optional boolean that when set will wait for "leave" animation to complete before starting "enter" animation of new element. Ideally we would also not need to worry about layout issues here and implement "hacks" like absolute positioning.

Motivation

I came across an issue similar to one described here #583
Essentially I want to create a page transition, where "initial" page fades out and only after it is not visible anymore "secondary" page fades in. This should be achievable without complex logic and delays.

Idea is taken from framer motion https://www.framer.com/api/motion/animate-presence/#animatepresenceprops.exitbeforeenter

I am down to try and implement this, but I am not sure where to start and if this is something that falls into the scope of the library.

Example

const transition = useTransition(toggle, {
   from: { opacity: 0 },
   enter: { opacity: 1 },
   leave: { opacity: 0 },
   exitBeforeEnter: true
});

// ...

transition((style, props) => {
  return <a.div style={style}>{toggle ? 🟢 : 🔴}</a.div> 
})

Metadata

Metadata

Assignees

Labels

kind: requestNew feature or request that should be actionedreleased in betathis has been released on a beta

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions