Options for orchestrating the timing of animations.

interface Orchestration {
    delay?: number;
    delayChildren?: number;
    staggerChildren?: number;
    staggerDirection?: number;
    when?: string | false;
}

Properties

delay?: number

Delay the animation by this duration (in seconds). Defaults to 0.

Remarks

const transition = {
delay: 0.2
}
delayChildren?: number

When using variants, children animations will start after this duration (in seconds). You can add the transition property to both the Frame and the variant directly. Adding it to the variant generally offers more flexibility, as it allows you to customize the delay per visual state.

const container = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: {
delayChildren: 0.5
}
}
}

const item = {
hidden: { opacity: 0 },
show: { opacity: 1 }
}

return (
<motion.ul
variants={container}
initial="hidden"
animate="show"
>
<motion.li variants={item} />
<motion.li variants={item} />
</motion.ul>
)
staggerChildren?: number

When using variants, animations of child components can be staggered by this duration (in seconds).

For instance, if staggerChildren is 0.01, the first child will be delayed by 0 seconds, the second by 0.01, the third by 0.02 and so on.

The calculated stagger delay will be added to delayChildren.

const container = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: {
staggerChildren: 0.5
}
}
}

const item = {
hidden: { opacity: 0 },
show: { opacity: 1 }
}

return (
<motion.ol
variants={container}
initial="hidden"
animate="show"
>
<motion.li variants={item} />
<motion.li variants={item} />
</motion.ol>
)
staggerDirection?: number

The direction in which to stagger children.

A value of 1 staggers from the first to the last while -1 staggers from the last to the first.

const container = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: {
staggerChildren: 0.5,
staggerDirection: -1
}
}
}

const item = {
hidden: { opacity: 0 },
show: { opacity: 1 }
}

return (
<motion.ul
variants={container}
initial="hidden"
animate="show"
>
<motion.li variants={item} size={50} />
<motion.li variants={item} size={50} />
</motion.ul>
)
when?: string | false

Describes the relationship between the transition and its children. Set to false by default.

Remarks

When using variants, the transition can be scheduled in relation to its children with either "beforeChildren" to finish this transition before starting children transitions, "afterChildren" to finish children transitions before starting this transition.

const list = {
hidden: {
opacity: 0,
transition: { when: "afterChildren" }
}
}

const item = {
hidden: {
opacity: 0,
transition: { duration: 2 }
}
}

return (
<motion.ul variants={list} animate="hidden">
<motion.li variants={item} />
<motion.li variants={item} />
</motion.ul>
)

Generated using TypeDoc