@wix/interact 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/react.js +1 -1
  3. package/dist/cjs/web.js +1 -1
  4. package/dist/es/index.js +1 -1
  5. package/dist/es/react.js +2 -2
  6. package/dist/es/web.js +2 -2
  7. package/dist/{index-BfcN_rkn.mjs → index-BP07b-Y1.mjs} +1202 -751
  8. package/dist/index-BP07b-Y1.mjs.map +1 -0
  9. package/dist/index-D4orAyUu.js +18 -0
  10. package/dist/index-D4orAyUu.js.map +1 -0
  11. package/dist/tsconfig.build.tsbuildinfo +1 -1
  12. package/dist/types/core/Interact.d.ts +12 -1
  13. package/dist/types/core/Interact.d.ts.map +1 -1
  14. package/dist/types/core/add.d.ts.map +1 -1
  15. package/dist/types/core/remove.d.ts.map +1 -1
  16. package/dist/types/handlers/animationEnd.d.ts +1 -1
  17. package/dist/types/handlers/animationEnd.d.ts.map +1 -1
  18. package/dist/types/handlers/effectHandlers.d.ts +2 -1
  19. package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
  20. package/dist/types/handlers/eventTrigger.d.ts +1 -1
  21. package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
  22. package/dist/types/handlers/viewEnter.d.ts +1 -1
  23. package/dist/types/handlers/viewEnter.d.ts.map +1 -1
  24. package/dist/types/types.d.ts +29 -2
  25. package/dist/types/types.d.ts.map +1 -1
  26. package/docs/api/types.md +114 -0
  27. package/docs/examples/README.md +10 -1
  28. package/docs/examples/list-patterns.md +148 -0
  29. package/docs/guides/README.md +5 -0
  30. package/docs/guides/sequences.md +421 -0
  31. package/package.json +2 -2
  32. package/rules/MASTER-CLEANUP-PLAN.md +286 -0
  33. package/rules/click.md +124 -32
  34. package/rules/full-lean.md +93 -7
  35. package/rules/hover.md +142 -153
  36. package/rules/integration.md +83 -82
  37. package/rules/pointermove.md +32 -57
  38. package/rules/scroll-list.md +82 -280
  39. package/rules/viewenter.md +158 -253
  40. package/rules/viewprogress.md +139 -845
  41. package/dist/index-BfcN_rkn.mjs.map +0 -1
  42. package/dist/index-HXLBEIjG.js +0 -18
  43. package/dist/index-HXLBEIjG.js.map +0 -1
@@ -0,0 +1,286 @@
1
+ # Master Cleanup Plan: `@wix/interact` Rule Files
2
+
3
+ Synthesized from three independent audits. Filtered through current best practices for documentation consumed by LLMs.
4
+
5
+ ---
6
+
7
+ ## Guiding Principles (Why This Matters)
8
+
9
+ These rules are the primary context fed to AI agents generating `@wix/interact` code. Every wasted token, every duplicated section, every drift between files directly degrades output quality. The standards we apply:
10
+
11
+ 1. **Token efficiency over completeness.** LLMs have broad web animation knowledge. Rules should focus exclusively on `@wix/interact`-specific contracts, constraints, and non-obvious patterns — not general CSS or animation education.
12
+ 2. **Single source of truth, always.** Duplicated content drifts. When it drifts, models get contradictory instructions and hedge or hallucinate.
13
+ 3. **Each file must be usable standalone.** The MCP loads one file at a time based on topic. A model fetching `"click"` gets only `click.md` — it will not automatically also receive `full-lean.md`. Each trigger file must therefore contain all `@wix/interact`-specific constraints the model needs for that trigger, including brief inline summaries of schema concepts it depends on.
14
+ 4. **Correctness over breadth.** A contradiction is worse than a gap. Fix all confirmed conflicts before any structural changes.
15
+ 5. **Describe when/how, not what/why at length.** A rule like `"alternate plays forward on enter, reverses on leave"` is worth keeping. A paragraph re-explaining what `IntersectionObserver` does is not.
16
+ 6. **Delete, don't redirect.** Generic web animation advice should be deleted entirely — not moved to a shared file or linked. The model already knows it. Cross-file links are useful for human navigation only; they are not a content delivery mechanism for the MCP.
17
+
18
+ ---
19
+
20
+ ## Current State
21
+
22
+ - 8 files, ~8,000+ lines
23
+ - ~30–40% estimated duplication
24
+ - 5 confirmed typos/errors
25
+ - 2 confirmed correctness contradictions
26
+ - 1 confirmed schema inconsistency between files (`listItemSelector` vs `selector`)
27
+
28
+ ---
29
+
30
+ ## Phase 1 — Fix Correctness Issues (do first, no structural work yet)
31
+
32
+ These are the highest-risk problems. A model following a contradictory rule produces wrong code.
33
+
34
+ ### 1.1 Resolve `keyframeEffect` + `pointerMove` conflict
35
+
36
+ **Conflict:**
37
+
38
+ - `full-lean.md` lines 366 and 403: "do NOT use `keyframeEffect` with `pointerMove` because pointer progress is two-dimensional"
39
+ - `full-lean.md` line 173: documents `axis?: 'x' | 'y'` param that collapses 2D progress to one axis for keyframes
40
+ - `pointermove.md`: Rules 10–11 document `keyframeEffect` + `axis` as a valid first-class pattern
41
+
42
+ **Resolution:** `full-lean.md` lines 366 and 403 are incomplete. The `axis` parameter exists precisely to make single-axis `keyframeEffect` valid. Update both lines to:
43
+
44
+ > Avoid `keyframeEffect` with `pointerMove` unless using `params: { axis: 'x' | 'y' }` to map a single pointer axis to linear 0–1 progress.
45
+
46
+ ### 1.2 Resolve `listItemSelector` vs `selector` inconsistency
47
+
48
+ **Conflict:**
49
+
50
+ - `full-lean.md` uses `listItemSelector` as the field name
51
+ - `integration.md` uses `selector` for the same concept
52
+
53
+ **Resolution:** Check the TypeScript type definition. Standardize both files to the correct field name. One of these is currently giving models the wrong API.
54
+
55
+ ### 1.3 Align FOUC constraints
56
+
57
+ **Conflict:**
58
+
59
+ - `full-lean.md` correctly restricts `data-interact-initial="true"` to: `viewEnter` trigger + `type: 'once'` + source element = target element
60
+ - `integration.md` gives the same code example but omits the constraints
61
+
62
+ **Resolution:** Add the full constraints explicitly to `integration.md`'s FOUC section.
63
+
64
+ ### 1.4 Fix `pointermove.md` undefined reference
65
+
66
+ `pointermove.md` has an example referencing `indicator-effect` which is not defined in the config shown. Fix the example to be self-contained.
67
+
68
+ ### 1.5 Fix all confirmed typos
69
+
70
+ | File | Line | Fix |
71
+ | ----------------- | ---- | ------------------------------------------------- |
72
+ | `viewenter.md` | 946 | `Guildelines` → `Guidelines` |
73
+ | `viewenter.md` | 980 | `HUge` → `Huge` |
74
+ | `viewprogress.md` | 43 | `effec` → `effect` |
75
+ | `hover.md` | 515 | `same ass` → `same as` |
76
+ | `integration.md` | 195 | `(Pre-built effect library)>` → remove stray `>` |
77
+ | `scroll-list.md` | 272 | `selector: ' .hero-image'` → remove leading space |
78
+
79
+ ---
80
+
81
+ ## Phase 2 — Establish Single Source of Truth (via deletion, not links)
82
+
83
+ ### 2.1 Define canonical ownership
84
+
85
+ Because the MCP loads one file at a time, the "canonical" column means "most complete definition lives here." The "inline mention needed" column means trigger docs that depend on this concept must include a brief self-contained summary — not a link, not a full re-explanation.
86
+
87
+ | Content | Canonical file | Action in other files | Inline mention needed in |
88
+ | ----------------------------------------------------------------------- | ---------------------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
89
+ | Full type/schema spec (`InteractConfig`, triggers, effects, conditions) | `full-lean.md` | Delete duplicated schema prose from `integration.md` | All trigger docs: keep brief summaries of params they use |
90
+ | Developer setup (install, web, react, CDN, `Interact.create`) | `integration.md` | — | — |
91
+ | FOUC / `generate(config)` | `full-lean.md` + `viewenter.md` | Delete full code block from `integration.md` only | `viewenter.md`: full working example with constraints — it is the most likely file fetched for entrance animations and must be self-contained |
92
+ | `StateParams.method` (`add`/`remove`/`toggle`/`clear`) | `full-lean.md` | — | `click.md`: inline comment on TransitionEffect rule only (`hover.md` has no TransitionEffect rule so no mention needed there) |
93
+ | Target cascade resolution | `full-lean.md` | — | Any trigger doc showing cross-targeting examples |
94
+ | `Progress` type for `customEffect` with `pointerMove` | `pointermove.md` | Delete duplicate definition from `full-lean.md` | — |
95
+ | `fill: 'both'` for `viewProgress` | `full-lean.md` | — | `viewprogress.md`: keep inline (model fetching viewprogress won't have full-lean) |
96
+ | `registerEffects` | currently only in `integration.md` | Add to `full-lean.md` | — |
97
+ | Generic perf/UX/a11y advice | nowhere — delete entirely | Remove from all trigger docs | — |
98
+
99
+ ### 2.2 Reduce `integration.md`
100
+
101
+ `integration.md` is a developer-facing onboarding guide — not a schema reference. Effect type syntax belongs in `full-lean.md`; the 3 end-to-end examples at the bottom of `integration.md` already demonstrate effect types in context, which is more useful for onboarding than standalone snippets.
102
+
103
+ - **Keep:** install steps, web/react setup snippets, `Interact.create` usage, HTML/JSX element wrappers, `registerEffects` setup, trigger overview table, 3 working examples (hover, viewEnter, click), FOUC rules
104
+ - **Delete:** full effect type taxonomy (`keyframeEffect`, `TransitionEffect`, scroll/mouse effect snippets) — covered by `full-lean.md` and shown contextually in the examples
105
+
106
+ ### 2.3 Strip generic best-practices content from all trigger docs
107
+
108
+ Do **not** create a shared `best-practices.md`. Instead, apply this filter to every trigger doc's Best Practices section:
109
+
110
+ **Delete (model already knows this):**
111
+
112
+ - "Use `transform`, `opacity`, `filter` for hardware acceleration"
113
+ - "Avoid animating layout properties"
114
+ - "`will-change` for complex animations"
115
+ - "Keep animations subtle"
116
+ - "Ensure content remains readable"
117
+ - "Progressive enhancement"
118
+ - Generic "Respect `prefers-reduced-motion`" without `@wix/interact`-specific guidance
119
+
120
+ **Keep (interact-specific, non-obvious):**
121
+
122
+ - `@wix/interact` conditions API for `prefers-reduced-motion`: how to wire it via `conditions` field. **Clarification:** condition IDs are user-defined strings — examples must always show the full `conditions` config map (with `type` and `predicate`) alongside the interaction that references them, not just the ID strings in isolation
123
+ - Trigger-specific timing constraints (e.g. click: 100–500ms, hover: 100–400ms)
124
+ - Trigger-specific gotchas (e.g. viewEnter: don't animate source and target as the same element with `repeat` type)
125
+ - `pointermove`: cache DOM queries outside `customEffect` callbacks
126
+ - `viewprogress`: stacking contexts freeze ViewTimeline — this belongs in `full-lean.md` general guidelines (already there) and should be removed from `viewprogress.md` best practices
127
+
128
+ **Estimated line savings: ~250 lines across trigger docs.**
129
+
130
+ ---
131
+
132
+ ## Phase 3 — Restructure `viewprogress.md`
133
+
134
+ This is the single largest structural problem. 9 rules are a 3×3 matrix with near-identical patterns:
135
+
136
+ | | `namedEffect` | `keyframeEffect` | `customEffect` |
137
+ | ------------------- | ------------- | ---------------- | -------------- |
138
+ | Parallax/Continuous | Rule 1 | Rule 4 | Rule 7 |
139
+ | Entry | Rule 2 | Rule 5 | Rule 8 |
140
+ | Exit | Rule 3 | Rule 6 | Rule 9 |
141
+
142
+ Every rule repeats the same config skeleton. Variable lists from Rule 5 onward explicitly say "Other variables same as Rule 1" — a direct admission of duplication.
143
+
144
+ **Why tables outperform the 9-rule format for LLM consumption:**
145
+
146
+ The 9-rule matrix looks comprehensive to humans but is inefficient for models. Once a model has seen the config pattern once, repeating it 8 more times with minor substitutions adds no information — it just consumes context tokens. The replacement structure (1 template + 2 lookup tables + 4 examples) performs better because:
147
+
148
+ - **Decision tables are scannable.** A model resolving "I need an entry animation" can map scenario → effect type → range names in one pass through the table, rather than pattern-matching a natural-language rule description to its task.
149
+ - **Fewer examples, correctly chosen, generalize better.** 4 curated examples (one per effect type + one non-obvious multi-range pattern) teach the model to compose, rather than encouraging copy-paste from the closest-matching rule.
150
+ - **Token efficiency directly affects output quality.** Fewer tokens spent on redundant patterns means more context budget for the actual user task.
151
+
152
+ The trade-off: the old format had a safer floor for weaker models that benefit from rote examples. The new format has a higher ceiling for capable models (Claude, GPT-4, Gemini) that generalize well from clean, structured docs — which is the target audience for this library.
153
+
154
+ ### Target structure for `viewprogress.md`
155
+
156
+ **Section 1: Core Concept** (~5 lines)
157
+ One sentence on what `viewProgress` does (scroll-driven via `ViewTimeline`). No animation education.
158
+
159
+ **Section 2: Config Template** (1 canonical pattern block)
160
+ Single pattern showing all `viewProgress`-relevant fields with placeholders.
161
+
162
+ **Section 3: Effect Type Selection** (table)
163
+
164
+ | Scenario | Effect type | Notes |
165
+ | -------------------------- | ---------------- | -------------------------------- | ----- | -------------------- |
166
+ | Use a scroll preset | `namedEffect` | Preferred; requires `range: 'in' | 'out' | 'continuous'` option |
167
+ | Custom CSS animation | `keyframeEffect` | Full keyframe control |
168
+ | DOM/canvas/dynamic content | `customEffect` | Last resort; keep callback lean |
169
+
170
+ **Section 4: Range Reference** (table)
171
+
172
+ | Intent | `rangeStart.name` | `rangeEnd.name` | Typical offsets |
173
+ | ------------------------- | ----------------- | --------------- | --------------- |
174
+ | Element entering viewport | `entry` | `entry` | 0–60% |
175
+ | Element exiting viewport | `exit` | `exit` | 0–60% |
176
+ | Full element traversal | `cover` | `cover` | 0–100% |
177
+ | While fully in viewport | `contain` | `contain` | 0–100% |
178
+
179
+ Include the offset semantics note (positive = forward along scroll axis) — once, here only.
180
+
181
+ **Section 5: Named Scroll Effects Reference** (condensed list)
182
+ The scroll preset names currently buried in Rule 1 variables — one list, not repeated across rules.
183
+
184
+ **Section 2 note: Config Template placeholders**
185
+ Do not include a `direction` placeholder. `direction` is a preset-specific option (not a standard field), its valid values differ per preset, and listing generic values would be incomplete and misleading. The template uses `[NAMED_EFFECT]` with a note: only use preset-specific options you have documentation for; omit and rely on defaults otherwise.
186
+
187
+ **Section 6: Examples** (4 total)
188
+
189
+ - `namedEffect` parallax
190
+ - `keyframeEffect` custom entrance
191
+ - `customEffect` scroll counter
192
+ - **Multi-range (entry + exit on the same element)** — non-obvious pattern requiring two effects with the same `key` but different range scopes. Without a dedicated example, models can infer it from the tables but may get the fill/easing direction wrong. The cost (~40 lines) is worth the reliability gain.
193
+
194
+ **Section 7: Advanced Patterns** — keep existing section as-is (genuinely unique content)
195
+
196
+ **Section 8: Best Practices** — interact-specific delta only (per Phase 2.3 filter above)
197
+
198
+ **Estimated line savings: ~~600 lines (~~55% reduction of the file).**
199
+
200
+ ---
201
+
202
+ ## Phase 4 — Reduce `scroll-list.md`
203
+
204
+ This file's genuine value is its list-specific patterns. Everything else repeats `viewprogress.md`.
205
+
206
+ ### Keep (unique to lists)
207
+
208
+ - Sticky container/item/content hierarchy explanation
209
+ - `listContainer` + `listItemSelector` (or `selector`) setup and rules
210
+ - Why `contain` range fits sticky container animations specifically
211
+ - Stagger pattern using shared `effectId` in the effects registry
212
+ - `customEffect` pattern for per-item dynamic content
213
+ - Responsive list animations section with a full `conditions` config map example (same pattern as other trigger docs — condition IDs are user-defined, must always be shown alongside their `type`/`predicate` definition)
214
+
215
+ ### Delete (generic, already in `viewprogress.md` or model already knows it)
216
+
217
+ - Range name semantics — already in `viewprogress.md` after Phase 3
218
+ - Effect type taxonomy — already in `viewprogress.md` after Phase 3
219
+ - Generic `fill: 'both'` explanation
220
+ - Generic performance/UX/a11y best practices (per Phase 2.3 filter)
221
+
222
+ **Estimated line savings: ~200 lines.**
223
+
224
+ ---
225
+
226
+ ## Phase 5 — Trigger Doc Standardization
227
+
228
+ Minor but important for model consistency. Models that see consistent structure learn to pattern-match faster across files.
229
+
230
+ ### Issues to fix
231
+
232
+ - `hover.md` title: "Hover Trigger Rules" — missing `for @wix/interact` (all others have it)
233
+ - `hover.md` has no Accessibility section (the only trigger doc missing it entirely) — add the interact-specific `conditions`-based reduced motion guidance
234
+ - Variable placeholder naming is inconsistent: `[SOURCE_KEY]` (viewprogress, pointermove) vs `[SOURCE_IDENTIFIER]` (click, hover) for the same concept
235
+ - `hover.md` Rules 2 and 3 overlap heavily (both are `alternate` pattern, one with `namedEffect`, one with `keyframeEffect`) — collapse into one rule with two examples
236
+ - `click.md` shows only `method: 'toggle'` for `TransitionEffect` — add brief mention that `add`, `remove`, `clear` also exist (already defined in `full-lean.md`, but models reading only the trigger doc will miss it)
237
+ - `hover.md` does **not** get a `method` mention — `hover.md` has no `TransitionEffect` rule, so adding a method summary there would be orphaned with no anchor
238
+
239
+ ### Fixes
240
+
241
+ - Standardize title format: `# [Trigger] Trigger Rules for @wix/interact`
242
+ - Add Accessibility section to `hover.md` (interact-specific content only)
243
+ - Standardize placeholder names across all trigger docs: use `[SOURCE_KEY]` / `[TARGET_KEY]` everywhere
244
+ - Collapse `hover.md` Rules 2+3 into one rule with two examples
245
+ - Add one-line mention of `add`/`remove`/`clear` methods to `click.md` TransitionEffect rule
246
+ - Remove trailing "These rules provide comprehensive coverage..." footers from `click.md`, `viewenter.md`, `viewprogress.md`, `pointermove.md`
247
+
248
+ ---
249
+
250
+ ## Final File Structure
251
+
252
+ ```
253
+ packages/interact/rules/
254
+ ├── full-lean.md ← canonical spec: schema, types, all trigger params, effect rules, general gotchas
255
+ │ changes: fix keyframeEffect+axis note, add registerEffects, remove duplicate Progress type
256
+ ├── integration.md ← onboarding only: setup, 3 working examples, trigger overview table
257
+ │ changes: reduce from ~370 → ~150 lines by deleting schema/effect prose
258
+ ├── click.md ← trigger patterns + examples + interact-specific best practices
259
+ ├── hover.md ← trigger patterns + examples; add a11y section; collapse rules 2+3
260
+ ├── viewenter.md ← trigger patterns + examples; full FOUC example with constraints
261
+ ├── viewprogress.md ← 1 template + 2 tables + 4 examples + advanced patterns
262
+ │ changes: remove 9-rule matrix (~600 lines); no direction placeholder in template
263
+ ├── scroll-list.md ← list-specific only (sticky hierarchy, stagger, list context)
264
+ │ changes: delete generic scroll/range/effect content (~200 lines)
265
+ └── pointermove.md ← keep Core Concepts (genuine unique value); trim best practices
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Execution Order
271
+
272
+ | # | Action | Files affected | Est. lines removed | Risk |
273
+ | --- | ------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------ | ------------------ |
274
+ | 1 | Fix correctness: `keyframeEffect`/`pointerMove` conflict | `full-lean.md` | — | High if skipped |
275
+ | 2 | Fix correctness: `listItemSelector` vs `selector` | `full-lean.md`, `integration.md` | — | High if skipped |
276
+ | 3 | Fix correctness: FOUC constraints alignment | `integration.md` | — | High if skipped |
277
+ | 4 | Fix 6 typos + undefined `pointermove.md` reference | all | — | Low effort, do now |
278
+ | 5 | Delete generic best-practices content from all trigger docs | all trigger docs | ~250 | Low |
279
+ | 6 | Refactor `viewprogress.md`: 1 template + 2 tables + 4 examples (added multi-range) | `viewprogress.md` | ~600 | Medium |
280
+ | 7 | Reduce `scroll-list.md`: delete generic scroll/range/effect content | `scroll-list.md` | ~200 | Low |
281
+ | 8 | Reduce `integration.md`: delete schema/effect prose | `integration.md` | ~150 | Low |
282
+ | 9 | Add `registerEffects` to `full-lean.md`; remove duplicate `Progress` type | `full-lean.md` | — | Low |
283
+ | 10 | Standardize titles, placeholders, collapse `hover.md` rules 2+3, add missing `method` mention, remove footers | all | ~50 | Very low |
284
+
285
+ **Estimated total reduction: ~~1,250 lines (~~15% of corpus), with zero loss of `@wix/interact`-specific information.**
286
+ The remaining content will be denser, more accurate, and cheaper for models to consume.
package/rules/click.md CHANGED
@@ -17,14 +17,14 @@ These rules help generate click-based interactions using the `@wix/interact` lib
17
17
 
18
18
  ```typescript
19
19
  {
20
- key: '[SOURCE_IDENTIFIER]',
20
+ key: '[SOURCE_KEY]',
21
21
  trigger: 'click',
22
22
  params: {
23
23
  type: 'alternate'
24
24
  },
25
25
  effects: [
26
26
  {
27
- key: '[TARGET_IDENTIFIER]',
27
+ key: '[TARGET_KEY]',
28
28
  [EFFECT_TYPE]: [EFFECT_DEFINITION],
29
29
  fill: 'both',
30
30
  reversed: [INITIAL_REVERSED_BOOL],
@@ -38,8 +38,8 @@ These rules help generate click-based interactions using the `@wix/interact` lib
38
38
 
39
39
  **Variables**:
40
40
 
41
- - `[SOURCE_IDENTIFIER]`: Unique identifier for clickable element (e.g., 'menu-button', 'accordion-header'). Should equal the value of the data-interact-key attribute on the wrapping interact-element.
42
- - `[TARGET_IDENTIFIER]`: Unique identifier for animated element (can be same as trigger or different). Should equal the value of the data-interact-key attribute on the wrapping interact-element.
41
+ - `[SOURCE_KEY]`: Unique identifier for clickable element. Should equal the value of the `data-interact-key` attribute on the wrapping `<interact-element>`.
42
+ - `[TARGET_KEY]`: Unique identifier for animated element (can be same as `[SOURCE_KEY]` for self-targeting, or different for cross-targeting).
43
43
  - `[EFFECT_TYPE]`: Either `namedEffect` or `keyframeEffect`
44
44
  - `[EFFECT_DEFINITION]`: Named effect object (e.g., { type: 'SlideIn', ...params }, { type: 'FadeIn', ...params }) or keyframe object (e.g., { name: 'custom-fade', keyframes: [{ opacity: 0 }, { opacity: 1 }] }, { name: 'custom-slide', keyframes: [{ transform: 'translateX(-100%)' }, { transform: 'translateX(0)' }] })
45
45
  - `[INITIAL_REVERSED_BOOL]`: Optional boolean value indicating whether the first toggle should play the reversed animation.
@@ -118,14 +118,14 @@ These rules help generate click-based interactions using the `@wix/interact` lib
118
118
 
119
119
  ```typescript
120
120
  {
121
- key: '[SOURCE_IDENTIFIER]',
121
+ key: '[SOURCE_KEY]',
122
122
  trigger: 'click',
123
123
  params: {
124
124
  type: 'state'
125
125
  },
126
126
  effects: [
127
127
  {
128
- key: '[TARGET_IDENTIFIER]',
128
+ key: '[TARGET_KEY]',
129
129
  [EFFECT_TYPE]: [EFFECT_DEFINITION],
130
130
  fill: 'both',
131
131
  reversed: [INITIAL_REVERSED_BOOL],
@@ -212,14 +212,14 @@ These rules help generate click-based interactions using the `@wix/interact` lib
212
212
 
213
213
  ```typescript
214
214
  {
215
- key: '[SOURCE_IDENTIFIER]',
215
+ key: '[SOURCE_KEY]',
216
216
  trigger: 'click',
217
217
  params: {
218
218
  type: 'repeat'
219
219
  },
220
220
  effects: [
221
221
  {
222
- key: '[TARGET_IDENTIFIER]',
222
+ key: '[TARGET_KEY]',
223
223
  [EFFECT_TYPE]: [EFFECT_DEFINITION],
224
224
  duration: [DURATION_MS],
225
225
  easing: '[EASING_FUNCTION]',
@@ -304,14 +304,14 @@ These rules help generate click-based interactions using the `@wix/interact` lib
304
304
 
305
305
  ```typescript
306
306
  {
307
- key: '[SOURCE_IDENTIFIER]',
307
+ key: '[SOURCE_KEY]',
308
308
  trigger: 'click',
309
309
  params: {
310
- method: 'toggle'
310
+ method: 'toggle' // also: 'add', 'remove', 'clear' — see full-lean.md StateParams
311
311
  },
312
312
  effects: [
313
313
  {
314
- key: '[TARGET_IDENTIFIER]',
314
+ key: '[TARGET_KEY]',
315
315
  transition: {
316
316
  duration: [DURATION_MS],
317
317
  delay: [DELAY_MS],
@@ -416,11 +416,122 @@ These rules help generate click-based interactions using the `@wix/interact` lib
416
416
 
417
417
  ---
418
418
 
419
+ ## Rule 5: Click with Sequence (Staggered Multi-Element Orchestration)
420
+
421
+ **Use Case**: Click-triggered coordinated animations across multiple elements with staggered timing (e.g., page section reveals, multi-element toggles, orchestrated content entrances)
422
+
423
+ **When to Apply**:
424
+
425
+ - When a click should animate multiple elements with staggered timing
426
+ - For orchestrated content reveals (heading, body, image in sequence)
427
+ - When you want easing-controlled stagger instead of manual delays
428
+ - For toggle-able multi-element sequences
429
+
430
+ **Pattern**:
431
+
432
+ ```typescript
433
+ {
434
+ key: '[SOURCE_KEY]',
435
+ trigger: 'click',
436
+ params: {
437
+ type: 'alternate'
438
+ },
439
+ sequences: [
440
+ {
441
+ offset: [OFFSET_MS],
442
+ offsetEasing: '[OFFSET_EASING]',
443
+ effects: [
444
+ { effectId: '[EFFECT_ID_1]', key: '[TARGET_KEY_1]' },
445
+ { effectId: '[EFFECT_ID_2]', key: '[TARGET_KEY_2]' },
446
+ { effectId: '[EFFECT_ID_3]', key: '[TARGET_KEY_3]' }
447
+ ]
448
+ }
449
+ ]
450
+ }
451
+ ```
452
+
453
+ **Variables**:
454
+
455
+ - `[OFFSET_MS]`: Stagger offset in ms between consecutive effects (typically 100-200ms)
456
+ - `[OFFSET_EASING]`: Easing for stagger distribution — `'linear'`, `'quadIn'`, `'sineOut'`, etc.
457
+ - `[EFFECT_ID_N]`: Effect id from the effects registry for each element
458
+ - `[TARGET_KEY_N]`: Element key for each target
459
+ - Other variables same as Rule 1
460
+
461
+ **Example - Orchestrated Content Reveal**:
462
+
463
+ ```typescript
464
+ {
465
+ key: 'reveal-button',
466
+ trigger: 'click',
467
+ params: {
468
+ type: 'alternate'
469
+ },
470
+ sequences: [
471
+ {
472
+ offset: 150,
473
+ offsetEasing: 'sineOut',
474
+ effects: [
475
+ { effectId: 'heading-entrance', key: 'content-heading' },
476
+ { effectId: 'body-entrance', key: 'content-body' },
477
+ { effectId: 'image-entrance', key: 'content-image' }
478
+ ]
479
+ }
480
+ ]
481
+ }
482
+ ```
483
+
484
+ ```typescript
485
+ effects: {
486
+ 'heading-entrance': {
487
+ key: 'content-heading',
488
+ duration: 600,
489
+ easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
490
+ keyframeEffect: {
491
+ name: 'heading-in',
492
+ keyframes: [
493
+ { transform: 'translateX(-40px)', opacity: 0 },
494
+ { transform: 'translateX(0)', opacity: 1 }
495
+ ]
496
+ },
497
+ fill: 'both'
498
+ },
499
+ 'body-entrance': {
500
+ key: 'content-body',
501
+ duration: 500,
502
+ easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
503
+ keyframeEffect: {
504
+ name: 'body-in',
505
+ keyframes: [
506
+ { transform: 'translateY(20px)', opacity: 0 },
507
+ { transform: 'translateY(0)', opacity: 1 }
508
+ ]
509
+ },
510
+ fill: 'both'
511
+ },
512
+ 'image-entrance': {
513
+ key: 'content-image',
514
+ duration: 700,
515
+ easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
516
+ keyframeEffect: {
517
+ name: 'image-in',
518
+ keyframes: [
519
+ { transform: 'scale(0.8) rotate(-5deg)', opacity: 0 },
520
+ { transform: 'scale(1) rotate(0deg)', opacity: 1 }
521
+ ]
522
+ },
523
+ fill: 'both'
524
+ }
525
+ }
526
+ ```
527
+
528
+ ---
529
+
419
530
  ## Advanced Patterns and Combinations
420
531
 
421
532
  ### Multi-Target Click Effects
422
533
 
423
- When one click should animate multiple elements:
534
+ When one click should animate multiple elements (without stagger, use `effects`; with stagger, prefer `sequences` above):
424
535
 
425
536
  ```typescript
426
537
  {
@@ -501,27 +612,12 @@ Using effectId for sequential animations:
501
612
 
502
613
  ## Best Practices for Click Interactions
503
614
 
504
- ### Performance Guidelines
615
+ ### Timing and Pattern Guidelines
505
616
 
506
617
  1. **Keep click animations short** (100-500ms) for immediate feedback
507
- 2. **Use `transform` and `opacity`** for smooth animations
508
- 3. **Avoid animating layout properties** like width/height in clicks
509
- 4. **Consider using `will-change`** for complex click animations
510
-
511
- ### User Experience Guidelines
512
-
513
- 1. **Provide immediate visual feedback** (within 100ms)
514
618
  2. **Use alternate pattern** for toggle states
515
619
  3. **Use repeat pattern** for confirmation actions
516
620
  4. **Use state pattern** for media controls
517
- 5. **Ensure click targets are accessible** (minimum 44px touch target)
518
-
519
- ### Accessibility Considerations
520
-
521
- 1. **Respect `prefers-reduced-motion`** setting
522
- 2. **Provide alternative interaction methods** (keyboard support)
523
- 3. **Ensure sufficient color contrast** during transitions
524
- 4. **Don't rely solely on animation** to convey state changes
525
621
 
526
622
  ### Common Use Cases by Pattern
527
623
 
@@ -555,7 +651,3 @@ Using effectId for sequential animations:
555
651
  - Color changes
556
652
  - Simple state toggles
557
653
  - CSS custom property updates
558
-
559
- ---
560
-
561
- These rules provide comprehensive coverage for click trigger interactions in `@wix/interact`, supporting the four main behavior patterns and two primary effect types as outlined in the development plan.