Sequences
A sequence is animations laid out in time and played as one, from createAnimate's animate. Each Segment starts as the one before ends, unless its at says otherwise.
const [scope, animate] = createAnimate()
const open = () =>
animate([
[".panel", { scaleY: [0, 1] }, { duration: 0.3 }],
"items",
["li", { opacity: [0, 1], x: [-12, 0] }, { delay: stagger(0.04), at: "-0.1" }],
[".close", { opacity: 1 }, { at: "items" }],
])animate(sequence, options?) returns playback controls, as a single animation does: await them, pause, seek or speed it up. For steps with your own code between them, such as a server's reply, yield each animation from a Solid 2 action: see Sequences as actions.
Segments
[subject, target, options?]animates elements, asanimate(subject, target, options)does: an element, a selector inside the scope, or a list.[batch, target, options?]animates a Batch's members, each through its own stops in the Batch: every member whose element has arrived, in member order, or one,grid.at(i). A value can be a function of a member's index and the Batch's count,(i, n) => …, as inanimate(grid, …).[callback, value?, options?]is a function Segment: its callback is given a value each frame, from 0 to 1, or through the stops you give, for what isn't an element's style, such as a counter or a canvas.- A label, a string, names the time where the Segment before ends, for a later
at.{ name, at }names a time of its own.
A Segment's options are a transition, its delay a number or stagger(), and at. A spring through two stops or fewer plays as an easing over its time to rest, so it fits the sequence's time.
A Batch's members
const grid = createBatch({ count: 100, initial: false, animate: (i) => ({ x: colX(i), y: rowY(i), opacity: 1 }) })
animate([
[grid, { y: (i) => [rowY(i) - 40, rowY(i)], opacity: [0, 1] }, { delay: stagger(0.01) }],
[grid, { x: (i) => colX(order[i]) }, { at: "+0.2", type: "spring", bounce: 0.2 }],
[".title", { opacity: 1 }],
])- Its keys are the Batch's, as numbers,
nullfor where a member is (or, after a stop, the stop before), or stops of them. A key the Batch doesn't have, or a string, is an error naming the key. stagger()counts the Segment's members, as Motion's sequences count a Segment's elements.animate(grid, …)counts only the members that move.- A member's element in a Segment of elements, by a selector or itself, moves its Batch keys in the Batch and the rest as any element's. A transform the Batch doesn't draw is an error naming it. A member named through the Batch and through its element is one subject, so the later Segment's stops replace the ones it overlaps, as they do for one element.
at
at | Where the Segment starts |
|---|---|
1.5 | Seconds into the sequence. |
"+0.5", "-0.5" | After, or before, the end of the Segment before. |
"<" | At the start of the Segment before. |
"<+0.5", "<-0.5" | After, or before, the start of the Segment before. |
"items" | At a label. |
Options
| Option | |
|---|---|
duration | The whole sequence, scaled to this many seconds. |
delay | Seconds before it starts. |
repeat, repeatType, repeatDelay | Plays it again: how many times, "loop", "reverse" or "mirror", and the pause between. |
defaultTransition | Each Segment's transition when it gives none: a 0.3 s easeOut tween otherwise. |
onComplete | Called as it lands. |
Coming from Motion
Motion's sequences, with its at, labels and options. Its motion value Segments are function Segments here.
Types
WardicAnimationSequence: a sequence.WardicSegment: one step of it.WardicElementSegment,WardicFunctionSegment,WardicBatchSegment: the three kinds of Segment.WardicBatchSegmentTarget,WardicBatchSegmentValue: a Batch Segment's values, key by key.WardicSegmentTarget,WardicSegmentOptions: a Segment's values and options.WardicSequenceLabel: a label.WardicSequenceTime: anat.WardicSequenceOptions: the sequence's options.