Skip to content

[FEATURE] Defining transitions between props #1725

Open
@mattgperry

Description

@mattgperry

There's a bit of a blind spot in the API at the moment where if you take

<motion.div
  initial={{ scale: 0 }}
  animate={{ scale: 1, transition: { delay: 1 } }}
  whileHover={{ scale: 2 }}
/>

For instance you can see that when we re-enter the animate state there'll be a delay applied. When really the delay naturally applies to the initial animation.

It'd be good if we could figure out a way to define a transition that applies just on the initial animation. Perhaps there's also value in being able to define specific transitions more generally, like whileHover -> animate?

<motion.div
  initial={{ scale: 0 }}
  animate={{ scale: 1, transition: { delay: 1 } }}
  whileHover={{ scale: 2 }}
  transition={{
    initial -> animate: {},
    whileHover -> animate: {}
  }}
/>

Or

<motion.div
  initial={{ scale: 0 }}
  animate={{
    scale: 1, 
    transitionFrom: {
      initial: { delay: 1 },
      whileHover: { type: "spring" }
    }
  }
  whileHover={{
    scale: 2
  }}
/>

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions