vael-ui v0.5.7

Motion guide · 5 of 8

Choreography

Inside a dialog or a popover, your own elements can join its motion. You name them, then time them against each other and against the panel. From your code, animate() plays a list of steps in order.

Which one to use

What starts the motion decides it, and whether a component is around your elements:

  • Elements that come in together, on the page or in a v-if: name each with v-animate:name and give it an after. Template only, no code.
  • Several of the same, such as rows or cards: one name and stagger.
  • Inside a dialog, a drawer or a popover: name them in its targets, and after times them against each other and the panel.
  • One element through several stops: steps.
  • Motion an event starts, such as a click, a saved form or a wrong code: animate([…]) from your code, or useAnimate() to scope it to a component.
  • A GSAP or motion timeline of your own: an enter hook that returns it.

One after another aftertargetsselect

Name your elements in targets, and mark them with the slot's target('name') or with v-animate:name. after: 'summary:60%' starts the rows when the summary is 60% of the way in. Elements with no component around them can wait on each other too, when they appear together: v-animate:body="{ after: 'title' }". Rows a component renders from data can't take a mark: give their name a select instead, such as targets: { rows: { select: 'tr' } }.

Moments

after waits for a moment in another element's motion:

  • 'summary': when it arrives
  • 'summary:start': when it starts
  • 'summary:settle': when its spring comes to rest
  • 'summary:40%': part of the way in
  • 'panel': the component's own parts work too
  • ['summary', 'chart']: when all of them arrive
  • 'tag', an element already on the page: when what it's playing now ends

On the page v-animate:nameafterstagger

Your elements don't need a component around them. Elements that come in together wait on each other by name: v-animate:lede="{ initial: { opacity: 0 }, after: 'title:50%' }" starts the lede halfway through the title's entrance. Under one name, a list staggers, and its after waits for whatever it names. Every moment above works here too. Mount them again and they play in again.

Stops along the way steps

steps moves an element through a series of stops. It holds at each stop until that stop's after moment comes.

In order, from code animate([…])atname

animate() also takes a list of steps, each [target, values, options], and plays them one after another, on the app's spring. Each step starts when the one before it ends, unless its at says otherwise. The controls steer the whole sequence: await it, pause() it, seek with time or reverse() it. Two steps on one element carry on from each other, and every end stays as the element's own style. In at, TypeScript suggests the names your steps declare and flags one that doesn't exist.

  • '+0.2': 0.2 seconds after the step before ends.
  • '-0.15': 0.15 seconds before it ends, so the two overlap.
  • '50%': halfway through the step before.
  • 1.2: 1.2 seconds from the start.
  • 'card': with the step given name: 'card', or 'card:60%': 60% of the way through it.

Your own timeline enterleave

An enter hook receives the parts, and your targets by name in its second argument: enter: ({ panel }, { targets }) => …. Name them in targets first, even with no values of their own. One GSAP timeline can then animate all of them. Return the timeline. The dialog waits for it, and stops it if you close early.