| name | Sequence docs and demos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| overview | Add documentation for the new Sequence/staggering feature to both the motion and interact docs, and create interactive demo components showcasing sequences with various triggers, easing functions, and configuration patterns. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| todos |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isProject | false |
API reference for the Sequence class, mirroring the style of animation-group.md. Contents:
- Overview -- Sequence extends AnimationGroup to coordinate multiple AnimationGroups with staggered delays
- Class definition -- constructor signature and properties:
constructor(animationGroups: AnimationGroup[], options?: SequenceOptions)| Property | Type | Default | Description |
|---|---|---|---|
animationGroups |
AnimationGroup[] |
Child groups managed by this Sequence | |
delay |
number |
0 |
Base delay applied to all groups |
offset |
number |
0 |
Stagger offset (ms) between consecutive groups |
offsetEasing |
(p: number) => number |
linear | Easing function for stagger distribution |
animations |
Animation[] |
Flattened array of all child animations (inherited) | |
ready |
Promise<void> |
Resolves when all offsets have been applied | |
isCSS |
boolean |
false |
Whether animations use CSS mode (inherited) |
**addGroups(entries: IndexedGroup[])**-- inserts new groups at specified indices, recalculates offsets viaapplyOffsets(), and resetsready. EachIndexedGrouphas{ index: number, group: AnimationGroup }.**removeGroups(predicate: (group: AnimationGroup) => boolean): AnimationGroup[]**-- removes groups matching the predicate, cancels their animations, recalculates offsets for remaining groups, resetsready, and returns the removed groups. Used when list items are dynamically removed.**onFinish(callback: () => void): Promise<void>**-- overrides AnimationGroup'sonFinishto await all child groupfinishedpromises before invoking the callback. Logs a warning for interrupted animations.- Offset calculation -- the formula
easing(i / last) * last * offset | 0with examples for linear, quadIn, sineOut (from the spec). Single-group sequences always return[0]. - Inherited playback API from AnimationGroup:
play(),pause(),reverse(),cancel(),progress(p),setPlaybackRate(rate),getProgress(),getTimingOptions(); getters:playState,finished - Usage examples -- creating a Sequence manually, controlling playback, using
addGroups/removeGroups, using different easing functions
API reference for the getSequence() and createAnimationGroups() functions (in packages/motion/src/motion.ts). Contents:
**getSequencesignature:**
function getSequence(
options: SequenceOptions,
animationGroups: AnimationGroupArgs[],
context?: Record<string, any>,
): Sequence;Each AnimationGroupArgs entry is resolved into one or more AnimationGroup instances. If a target resolves to multiple elements (e.g. HTMLElement[] or a CSS selector string), each element becomes a separate group in the Sequence.
**createAnimationGroupssignature:**
function createAnimationGroups(
animationGroupArgs: AnimationGroupArgs[],
context?: Record<string, any>,
): AnimationGroup[];Builds AnimationGroup[] from args without wrapping in a Sequence. Used internally by getSequence and by Interact.addToSequence() when adding groups to an existing Sequence.
**AnimationGroupArgstype:**
type AnimationGroupArgs = {
target: HTMLElement | HTMLElement[] | string | null;
options: AnimationOptions;
context?: Record<string, any>;
};- Examples -- creating a staggered entrance for a list of elements, using different offset easings, building groups independently with
createAnimationGroups
Add entries to the API index under "Core Functions":
### [Sequence](sequence.md)-- Coordinates multiple AnimationGroups with staggered delay offsets### [Sequence Creation](get-sequence.md)--getSequence()andcreateAnimationGroups()factory functions
Add to "Quick Reference" section:
// Sequence creation
const sequence = getSequence(
{ offset: 200, offsetEasing: 'quadIn' },
items.map((el) => ({ target: el, options: { name: 'FadeIn' } })),
);
sequence.play();Add to "Types Overview": SequenceOptions, AnimationGroupArgs, IndexedGroup
Add new section ## Sequence Types with:
type SequenceOptions = {
delay?: number;
offset?: number;
offsetEasing?: string | ((p: number) => number);
};
type AnimationGroupArgs = {
target: HTMLElement | HTMLElement[] | string | null;
options: AnimationOptions;
context?: Record<string, any>;
};
type IndexedGroup = {
index: number;
group: AnimationGroup;
};Include property descriptions and usage examples for each type.
Add a "Sequences & Staggering" section under "Advanced Concepts" explaining:
- Concept -- Sequences coordinate multiple AnimationGroups as a single timeline with easing-driven stagger delays
- Offset model -- how
offsetdistributes delay across groups using the formulaeasing(i / last) * last * offset | 0 - Easing curves -- visual explanation of how
linear,quadIn,sineOut, and customcubic-bezieraffect stagger timing (quadIn = slow start then rapid, sineOut = fast start then gradual) - Dynamic groups --
addGroupsfor adding elements (e.g. new list items) andremoveGroupsfor cleanup when elements are removed, both triggering automatic offset recalculation - Relationship to AnimationGroup -- Sequence inherits all playback controls; child groups are stored in
animationGroupswhileanimationscontains the flattened array
Comprehensive guide for using sequences in Interact configs. Contents:
- What is a Sequence -- a list of Effects managed as a coordinated timeline with staggered delays, built on top of the Motion
Sequenceclass - Config structure -- two levels of sequence definition:
InteractConfig.sequences-- reusable named sequences (keyed map, resolved bysequenceId)Interaction.sequences-- per-interaction sequence list (inlineSequenceConfigorSequenceConfigRefreferences)- An interaction can have both
effectsandsequences, or either alone
- SequenceConfig -- inline sequence definition:
type SequenceConfig = SequenceOptionsConfig & {
effects: (Effect | EffectRef)[];
};- SequenceConfigRef -- referencing a reusable sequence by ID with optional inline overrides:
type SequenceConfigRef = {
sequenceId: string;
delay?: number;
offset?: number;
offsetEasing?: string | ((p: number) => number);
conditions?: string[];
};- SequenceOptionsConfig -- shared options (includes
conditionsfor media-query gating):
type SequenceOptionsConfig = {
delay?: number;
offset?: number;
offsetEasing?: string | ((p: number) => number);
sequenceId?: string;
conditions?: string[];
};- Offset and easing -- how offset distributes delay across effects, easing curves (linear, quadIn, sineOut), visual formula
easing(i / last) * last * offset | 0 - Cross-element sequences -- effects targeting different
keyvalues within a single sequence, resolved at add-time via_processSequencesForTarget. When a sequence effect targets a different key than the source interaction, Interact waits for both elements to be registered before creating the Sequence. - Sequences with listContainer -- staggering list items:
- Initial
add()creates the Sequence with all existing list items addListItems()callsInteract.addToSequence()withIndexedGroupentries at the correct indices, triggering offset recalculationremoveListItems()callsInteract.removeFromSequences()which uses theelementSequenceMapWeakMap for O(1) lookup and callssequence.removeGroups()with a predicate matching the removed element's animations- Each
addListItemscall uses a unique cache key (${cacheKey}::${generateId()}) for its Sequence
- Initial
- Element removal and cleanup -- how
Interact.removeFromSequences(elements)useselementSequenceMap(aWeakMap<HTMLElement, Set<Sequence>>) for efficient element-to-sequence lookup, callsremoveGroupson each associated Sequence, and deletes the element from the map. Called automatically fromremoveListItems. - Conditions on sequences -- sequence-level
conditionsarray gates the entire sequence; individual effect-level conditions withineffectscan gate specific effects. Both set upmatchMedialisteners for dynamic add/remove. - Sequence caching --
Interact.sequenceCache(Map<string, Sequence>) prevents duplicate Sequences for the same interaction/key combination.Interact.destroy()andclearInteractionStateForKey()clean up cache entries. - Examples -- staggered card grid entrance (viewEnter + listContainer), multi-element orchestration (cross-key sequence), click-triggered alternate sequence, sequence with media-query conditions
Add new section ## Sequence Types with type definitions:
SequenceOptionsConfig-- with all properties includingconditions?: string[]SequenceConfig--SequenceOptionsConfig & { effects: (Effect | EffectRef)[] }SequenceConfigRef-- reference type withsequenceIdand optional overrides +conditions- Updated
InteractConfigshowingsequences?: Record<string, SequenceConfig> - Updated
Interactionshowingsequences?: (SequenceConfig | SequenceConfigRef)[]with note on mutual exclusivity branches (effects-only, sequences-only, or both) - Updated
InteractCacheshowingsequences: { [sequenceId: string]: SequenceConfig }andinteractions[path].sequences: Record<string, (InteractionTrigger & { sequence: SequenceConfig })[]>
Add new static methods and properties under "Static Methods":
**Interact.getSequence(cacheKey, sequenceOptions, animationGroupArgs, context?)**- Parameters:
cacheKey: string,sequenceOptions: SequenceOptions,animationGroupArgs: AnimationGroupArgs[],context?: { reducedMotion?: boolean } - Returns:
Sequence - Details: Returns cached Sequence if one exists for
cacheKey, otherwise creates viagetSequence()from@wix/motion, caches it, and registers target elements inelementSequenceMap
- Parameters:
**Interact.addToSequence(cacheKey, animationGroupArgs, indices, context?)**- Parameters:
cacheKey: string,animationGroupArgs: AnimationGroupArgs[],indices: number[],context?: { reducedMotion?: boolean } - Returns:
boolean(false if no cached Sequence found forcacheKey) - Details: Builds new
AnimationGroupinstances viacreateAnimationGroups(), maps them toIndexedGroup[]usingindices, callscached.addGroups(entries), and registers new elements inelementSequenceMap
- Parameters:
**Interact.removeFromSequences(elements)**- Parameters:
elements: HTMLElement[] - Returns:
void - Details: For each element, looks up associated Sequences via
elementSequenceMap, callssequence.removeGroups()with a predicate matching animations targeting that element, and deletes the element from the map
- Parameters:
**Interact.sequenceCache**--Map<string, Sequence>static property, cleared ondestroy()**Interact.elementSequenceMap**--WeakMap<HTMLElement, Set<Sequence>>static property, reset ondestroy(). Provides O(1) element-to-Sequence lookup for efficient removal.
Add entry under guide list:
### 🎼 Sequences & Staggering-- Coordinate multiple effects with staggered timing, offset easing, and dynamic list management. Link toguides/sequences.md.
**examples/README.md:**
- Add "Sequence Animations" category under "Example Categories" with sub-items: Staggered List Entrance, Cross-Element Orchestration, Click-Triggered Sequence, Easing Comparison
- Update "Advanced Patterns > Animation Sequences" to reference the new
sequencesconfig syntax as the preferred approach
**examples/list-patterns.md:**
- Add new section
## Sequence-Based Staggeringwith examples showing:- Staggered list entrance using
Interaction.sequenceswithlistContainer - Dynamic list items with
addListItemstriggeringaddToSequence - Different
offsetEasingvalues (linear vs quadIn vs sineOut) for list stagger - Sequence with removal: how removing list items automatically cleans up via
removeFromSequences
- Staggered list entrance using
Create demo components in both src/web/components/ and src/react/components/ (following the existing mirror pattern). Each demo uses the useInteractInstance hook and the existing panel/control UI patterns.
An interactive demo (like the existing Playground.tsx) where the user can tune sequence parameters in real time:
- Controls: offset (0-500ms slider), offsetEasing (dropdown: linear, quadIn, quadOut, sineOut, cubic-bezier), delay (0-500ms), duration per effect, trigger type (viewEnter, click)
- Preview: a grid of 6-8 cards, each as an effect in a sequence, using
keyframeEffect(e.g. fade+slide-up) - Config display: shows the live
InteractConfigJSON being used - Uses
Interaction.sequenceswith inline sequence definition
A scroll-triggered staggered entrance showcasing the most common use case:
- A list of cards inside a
listContainer, entering the viewport with staggeredviewEntertrigger - Demonstrates
offset+offsetEasing: 'quadIn'for natural-feeling stagger - Showcases both inline and reusable (
sequenceId) sequence definitions
A click-triggered multi-element orchestration:
- A button triggers a sequence that animates multiple elements (heading, body text, image) in coordinated order
- Demonstrates cross-element targeting (effects with different
keyvalues in the sequence) - Uses
clicktrigger withtype: 'alternate'for play/reverse
A visual comparison of different offsetEasing values:
- 3-4 rows, each showing the same set of items but with different easing (linear, quadIn, sineOut, cubicBezier)
- All triggered simultaneously on a button click or viewEnter
- Labels showing easing name and computed delay values
Add the new demo components to both App files, with appropriate section titles. Add a "Sequences" section header separating existing demos from the new sequence demos.
Add styles for the new sequence demo components (card grids, easing comparison rows, sequence preview areas). Follow the existing design system (Space Grotesk/Inter fonts, dark panels, blue accent).
| Action | Path |
|---|---|
| Create | packages/motion/docs/api/sequence.md |
| Create | packages/motion/docs/api/get-sequence.md |
| Edit | packages/motion/docs/api/README.md |
| Edit | packages/motion/docs/api/types.md |
| Edit | packages/motion/docs/core-concepts.md |
| Create | packages/interact/docs/guides/sequences.md |
| Edit | packages/interact/docs/api/types.md |
| Edit | packages/interact/docs/api/interact-class.md |
| Edit | packages/interact/docs/guides/README.md |
| Edit | packages/interact/docs/examples/README.md |
| Edit | packages/interact/docs/examples/list-patterns.md |
| Create | apps/demo/src/web/components/SequencePlayground.tsx |
| Create | apps/demo/src/web/components/SequenceEntranceDemo.tsx |
| Create | apps/demo/src/web/components/SequenceClickDemo.tsx |
| Create | apps/demo/src/web/components/SequenceEasingComparison.tsx |
| Create | apps/demo/src/react/components/SequencePlayground.tsx |
| Create | apps/demo/src/react/components/SequenceEntranceDemo.tsx |
| Create | apps/demo/src/react/components/SequenceClickDemo.tsx |
| Create | apps/demo/src/react/components/SequenceEasingComparison.tsx |
| Edit | apps/demo/src/web/App.tsx |
| Edit | apps/demo/src/react/App.tsx |
| Edit | apps/demo/src/styles.css |