@wix/interact 2.1.4 → 2.2.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.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react.js +1 -1
- package/dist/cjs/web.js +1 -1
- package/dist/cjs/web.js.map +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/react.js +2 -2
- package/dist/es/web.js +15 -15
- package/dist/es/web.js.map +1 -1
- package/dist/{index-DHqlFmW8.mjs → index-ByLXasWO.mjs} +491 -485
- package/dist/index-ByLXasWO.mjs.map +1 -0
- package/dist/index-CzRuJxn8.js +18 -0
- package/dist/index-CzRuJxn8.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/core/Interact.d.ts +2 -2
- package/dist/types/core/InteractionController.d.ts +2 -2
- package/dist/types/core/InteractionController.d.ts.map +1 -1
- package/dist/types/core/add.d.ts.map +1 -1
- package/dist/types/core/css.d.ts.map +1 -1
- package/dist/types/handlers/effectHandlers.d.ts +4 -4
- package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
- package/dist/types/handlers/eventTrigger.d.ts +2 -2
- package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
- package/dist/types/handlers/index.d.ts.map +1 -1
- package/dist/types/handlers/viewEnter.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/react/index.d.ts +1 -1
- package/dist/types/react/index.d.ts.map +1 -1
- package/dist/types/types/config.d.ts +47 -0
- package/dist/types/types/config.d.ts.map +1 -0
- package/dist/types/types/controller.d.ts +34 -0
- package/dist/types/types/controller.d.ts.map +1 -0
- package/dist/types/types/effects.d.ts +75 -0
- package/dist/types/types/effects.d.ts.map +1 -0
- package/dist/types/types/external.d.ts +6 -0
- package/dist/types/types/external.d.ts.map +1 -0
- package/dist/types/types/global.d.ts +11 -0
- package/dist/types/types/global.d.ts.map +1 -0
- package/dist/types/types/handlers.d.ts +41 -0
- package/dist/types/types/handlers.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +8 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/internal.d.ts +36 -0
- package/dist/types/types/internal.d.ts.map +1 -0
- package/dist/types/types/triggers.d.ts +28 -0
- package/dist/types/types/triggers.d.ts.map +1 -0
- package/dist/types/web/InteractElement.d.ts +2 -2
- package/dist/types/web/InteractElement.d.ts.map +1 -1
- package/dist/types/web/index.d.ts +1 -1
- package/dist/types/web/index.d.ts.map +1 -1
- package/docs/api/README.md +2 -3
- package/docs/api/functions.md +4 -4
- package/docs/api/interact-class.md +2 -3
- package/docs/api/interact-element.md +2 -2
- package/docs/api/interaction-controller.md +4 -4
- package/docs/api/types.md +38 -69
- package/docs/examples/README.md +1 -1
- package/docs/examples/click-interactions.md +0 -7
- package/docs/examples/entrance-animations.md +28 -27
- package/docs/examples/list-patterns.md +17 -16
- package/docs/guides/conditions-and-media-queries.md +2 -3
- package/docs/guides/configuration-structure.md +5 -7
- package/docs/guides/effects-and-animations.md +2 -4
- package/docs/guides/getting-started.md +0 -1
- package/docs/guides/lists-and-dynamic-content.md +10 -9
- package/docs/guides/sequences.md +3 -4
- package/docs/guides/state-management.md +0 -2
- package/docs/guides/understanding-triggers.md +9 -13
- package/package.json +2 -2
- package/rules/click.md +96 -560
- package/rules/full-lean.md +536 -360
- package/rules/hover.md +107 -530
- package/rules/integration.md +212 -261
- package/rules/pointermove.md +154 -1407
- package/rules/viewenter.md +128 -863
- package/rules/viewprogress.md +88 -322
- package/dist/index-DHqlFmW8.mjs.map +0 -1
- package/dist/index-DYEvpIGz.js +0 -18
- package/dist/index-DYEvpIGz.js.map +0 -1
- package/dist/types/types.d.ts +0 -256
- package/dist/types/types.d.ts.map +0 -1
- package/rules/MASTER-CLEANUP-PLAN.md +0 -286
- package/rules/scroll-list.md +0 -748
package/rules/click.md
CHANGED
|
@@ -1,653 +1,189 @@
|
|
|
1
1
|
# Click Trigger Rules for @wix/interact
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This document contains rules for generating click-triggered interactions in `@wix/interact`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**CRITICAL — Accessible click**: Use `trigger: 'activate'` instead of `trigger: 'click'` to also respond to keyboard activation (Enter / Space).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Table of Contents
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- When creating expand/collapse functionality
|
|
14
|
-
- For modal or sidebar open/close animations
|
|
15
|
-
|
|
16
|
-
**Pattern**:
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
{
|
|
20
|
-
key: '[SOURCE_KEY]',
|
|
21
|
-
trigger: 'click',
|
|
22
|
-
params: {
|
|
23
|
-
type: 'alternate'
|
|
24
|
-
},
|
|
25
|
-
effects: [
|
|
26
|
-
{
|
|
27
|
-
key: '[TARGET_KEY]',
|
|
28
|
-
[EFFECT_TYPE]: [EFFECT_DEFINITION],
|
|
29
|
-
fill: 'both',
|
|
30
|
-
reversed: [INITIAL_REVERSED_BOOL],
|
|
31
|
-
duration: [DURATION_MS],
|
|
32
|
-
easing: '[EASING_FUNCTION]',
|
|
33
|
-
effectId: '[UNIQUE_EFFECT_ID]'
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**Variables**:
|
|
40
|
-
|
|
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
|
-
- `[EFFECT_TYPE]`: Either `namedEffect` or `keyframeEffect`
|
|
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
|
-
- `[INITIAL_REVERSED_BOOL]`: Optional boolean value indicating whether the first toggle should play the reversed animation.
|
|
46
|
-
- `[DURATION_MS]`: Animation duration in milliseconds (typically 200-500ms for clicks)
|
|
47
|
-
- `[EASING_FUNCTION]`: Timing function ('ease-out', 'ease-in-out', or cubic-bezier)
|
|
48
|
-
- `[UNIQUE_EFFECT_ID]`: Optional unique identifier for animation chaining
|
|
49
|
-
|
|
50
|
-
**Example - Menu Toggle**:
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
{
|
|
54
|
-
key: 'hamburger-menu',
|
|
55
|
-
trigger: 'click',
|
|
56
|
-
params: {
|
|
57
|
-
type: 'alternate'
|
|
58
|
-
},
|
|
59
|
-
effects: [
|
|
60
|
-
{
|
|
61
|
-
key: 'mobile-nav',
|
|
62
|
-
namedEffect: {
|
|
63
|
-
type: 'SlideIn',
|
|
64
|
-
direction: 'left'
|
|
65
|
-
},
|
|
66
|
-
fill: 'both',
|
|
67
|
-
reversed: true,
|
|
68
|
-
duration: 300,
|
|
69
|
-
easing: 'ease-out',
|
|
70
|
-
effectId: 'mobile-nav-toggle'
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**Example - Accordion Expand**:
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
{
|
|
80
|
-
key: 'accordion-header',
|
|
81
|
-
trigger: 'click',
|
|
82
|
-
params: {
|
|
83
|
-
type: 'alternate'
|
|
84
|
-
},
|
|
85
|
-
effects: [
|
|
86
|
-
{
|
|
87
|
-
key: 'accordion-content',
|
|
88
|
-
keyframeEffect: {
|
|
89
|
-
name: 'accordion',
|
|
90
|
-
keyframes: [
|
|
91
|
-
{ clipPath: 'inset(0 0 100% 0)', opacity: '0' },
|
|
92
|
-
{ clipPath: 'inset(0 0 0 0)', opacity: '1' }
|
|
93
|
-
]
|
|
94
|
-
},
|
|
95
|
-
fill: 'both',
|
|
96
|
-
reversed: true,
|
|
97
|
-
duration: 400,
|
|
98
|
-
easing: 'ease-in-out'
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
```
|
|
9
|
+
- [Rule 1: keyframeEffect / namedEffect (TimeEffect)](#rule-1-keyframeeffect--namedeffect-timeeffect)
|
|
10
|
+
- [Rule 2: transition / transitionProperties (StateEffect)](#rule-2-transition--transitionproperties-stateeffect)
|
|
11
|
+
- [Rule 3: customEffect (TimeEffect)](#rule-3-customeffect-timeeffect)
|
|
12
|
+
- [Rule 4: Sequences](#rule-4-sequences)
|
|
103
13
|
|
|
104
14
|
---
|
|
105
15
|
|
|
106
|
-
## Rule
|
|
16
|
+
## Rule 1: keyframeEffect / namedEffect (TimeEffect)
|
|
107
17
|
|
|
108
|
-
|
|
18
|
+
Use `keyframeEffect` or `namedEffect` when the click should play an animation (CSS or WAAPI). Set `triggerType` on each effect to control playback behavior.
|
|
109
19
|
|
|
110
|
-
**
|
|
111
|
-
|
|
112
|
-
- When you need play/pause functionality
|
|
113
|
-
- For controlling ongoing animations
|
|
114
|
-
- When users should be able to interrupt and resume animations
|
|
115
|
-
- For interactive media controls
|
|
116
|
-
|
|
117
|
-
**Pattern**:
|
|
20
|
+
**CRITICAL:** Always include `fill: 'both'` for `triggerType: 'alternate'` or `'repeat'` — keeps the effect applied while finished and prevents garbage-collection, allowing efficient toggling. For `triggerType: 'once'` use `fill: 'backwards'`.
|
|
118
21
|
|
|
119
22
|
```typescript
|
|
120
23
|
{
|
|
121
24
|
key: '[SOURCE_KEY]',
|
|
122
25
|
trigger: 'click',
|
|
123
|
-
params: {
|
|
124
|
-
type: 'state'
|
|
125
|
-
},
|
|
126
26
|
effects: [
|
|
127
27
|
{
|
|
128
28
|
key: '[TARGET_KEY]',
|
|
129
|
-
|
|
130
|
-
fill: 'both',
|
|
131
|
-
reversed: [INITIAL_REVERSED_BOOL],
|
|
132
|
-
duration: [DURATION_MS],
|
|
133
|
-
easing: '[EASING_FUNCTION]',
|
|
134
|
-
iterations: [ITERATION_COUNT],
|
|
135
|
-
alternate: [ALTERNATE_BOOL],
|
|
136
|
-
effectId: '[UNIQUE_EFFECT_ID]'
|
|
137
|
-
}
|
|
138
|
-
]
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Variables**:
|
|
29
|
+
triggerType: '[TRIGGER_TYPE]',
|
|
143
30
|
|
|
144
|
-
|
|
145
|
-
- `[ALTERNATE_BOOL]`: Optional boolean value indicating whether to alternate/toggle the playing direction of the animation on each iterations. Relevant only if `[ITERATION_COUNT]` is not 1.
|
|
146
|
-
- Other variables same as Rule 1
|
|
147
|
-
|
|
148
|
-
**Example - Loading Spinner Control**:
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
{
|
|
152
|
-
key: 'loading-control',
|
|
153
|
-
trigger: 'click',
|
|
154
|
-
params: {
|
|
155
|
-
type: 'state'
|
|
156
|
-
},
|
|
157
|
-
effects: [
|
|
158
|
-
{
|
|
159
|
-
key: 'spinner',
|
|
31
|
+
// --- pick ONE of the two effect types ---
|
|
160
32
|
keyframeEffect: {
|
|
161
|
-
name: '
|
|
162
|
-
keyframes: [
|
|
163
|
-
{ transform: 'rotate(0deg)' },
|
|
164
|
-
{ transform: 'rotate(360deg)' }
|
|
165
|
-
]
|
|
33
|
+
name: '[EFFECT_NAME]',
|
|
34
|
+
keyframes: [KEYFRAMES],
|
|
166
35
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
iterations: Infinity,
|
|
170
|
-
effectId: 'spinner-rotation'
|
|
171
|
-
}
|
|
172
|
-
]
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
**Example - Slideshow Pause**:
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
{
|
|
180
|
-
key: 'slideshow-toggle',
|
|
181
|
-
trigger: 'click',
|
|
182
|
-
params: {
|
|
183
|
-
type: 'state'
|
|
184
|
-
},
|
|
185
|
-
effects: [
|
|
186
|
-
{
|
|
187
|
-
key: 'slideshow-container',
|
|
188
|
-
namedEffect: { type: 'ShuttersIn' },
|
|
189
|
-
duration: 3000,
|
|
190
|
-
iterations: 10,
|
|
191
|
-
alternate: true,
|
|
192
|
-
effectId: 'slideshow-animation'
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## Rule 3: Click with TimeEffect and Repeat Pattern
|
|
36
|
+
// OR
|
|
37
|
+
namedEffect: [NAMED_EFFECT_DEFINITION],
|
|
201
38
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
**When to Apply**:
|
|
205
|
-
|
|
206
|
-
- When you want fresh animation on each click
|
|
207
|
-
- For attention-grabbing effects
|
|
208
|
-
- When animation should always start from initial state
|
|
209
|
-
- For feedback animations that confirm user actions
|
|
210
|
-
|
|
211
|
-
**Pattern**:
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
{
|
|
215
|
-
key: '[SOURCE_KEY]',
|
|
216
|
-
trigger: 'click',
|
|
217
|
-
params: {
|
|
218
|
-
type: 'repeat'
|
|
219
|
-
},
|
|
220
|
-
effects: [
|
|
221
|
-
{
|
|
222
|
-
key: '[TARGET_KEY]',
|
|
223
|
-
[EFFECT_TYPE]: [EFFECT_DEFINITION],
|
|
39
|
+
fill: '[FILL_MODE]',
|
|
40
|
+
reversed: [INITIAL_REVERSED_BOOL],
|
|
224
41
|
duration: [DURATION_MS],
|
|
225
42
|
easing: '[EASING_FUNCTION]',
|
|
226
43
|
delay: [DELAY_MS],
|
|
44
|
+
iterations: [ITERATIONS],
|
|
45
|
+
alternate: [ALTERNATE_BOOL],
|
|
227
46
|
effectId: '[UNIQUE_EFFECT_ID]'
|
|
228
|
-
}
|
|
47
|
+
},
|
|
48
|
+
// additional effects targeting other elements can be added here
|
|
229
49
|
]
|
|
230
50
|
}
|
|
231
51
|
```
|
|
232
52
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
- `[DELAY_MS]`: Optional delay before animation starts (useful for sequencing)
|
|
236
|
-
- Other variables same as Rule 1
|
|
237
|
-
|
|
238
|
-
**Example - Button Pulse Feedback**:
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
{
|
|
242
|
-
key: 'action-button',
|
|
243
|
-
trigger: 'click',
|
|
244
|
-
params: {
|
|
245
|
-
type: 'repeat'
|
|
246
|
-
},
|
|
247
|
-
effects: [
|
|
248
|
-
{
|
|
249
|
-
key: 'action-button',
|
|
250
|
-
keyframeEffect: {
|
|
251
|
-
name: 'button-shadow',
|
|
252
|
-
keyframes: [
|
|
253
|
-
{ transform: 'scale(1)', boxShadow: '0 2px 4px rgba(0,0,0,0.1)' },
|
|
254
|
-
{ transform: 'scale(1.1)', boxShadow: '0 8px 16px rgba(0,0,0,0.2)' },
|
|
255
|
-
{ transform: 'scale(1)', boxShadow: '0 2px 4px rgba(0,0,0,0.1)' }
|
|
256
|
-
]
|
|
257
|
-
},
|
|
258
|
-
duration: 300,
|
|
259
|
-
easing: 'ease-out'
|
|
260
|
-
}
|
|
261
|
-
]
|
|
262
|
-
}
|
|
263
|
-
```
|
|
53
|
+
### Variables
|
|
264
54
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
delay: 300,
|
|
284
|
-
effectId: 'success-feedback'
|
|
285
|
-
}
|
|
286
|
-
]
|
|
287
|
-
}
|
|
288
|
-
```
|
|
55
|
+
- `[SOURCE_KEY]` — identifier matching the element's key (`data-interact-key` for web, `interactKey` for React). The element that listens for clicks.
|
|
56
|
+
- `[TARGET_KEY]` — identifier matching the element's key on the element that animates. If missing it defaults to `[SOURCE_KEY]` for targeting the source element.
|
|
57
|
+
- `[TRIGGER_TYPE]` — `triggerType` on the effect. One of:
|
|
58
|
+
- `'alternate'` — plays forward on first click, reverses on next click. Default.
|
|
59
|
+
- `'repeat'` — restarts the animation from the beginning on each click.
|
|
60
|
+
- `'once'` — plays once on the first click and never again.
|
|
61
|
+
- `'state'` — resumes/pauses the animation on each click. Useful for continuous loops (`iterations: Infinity`).
|
|
62
|
+
- `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names in camelCase.
|
|
63
|
+
- `[EFFECT_NAME]` — unique string identifier for a `keyframeEffect`.
|
|
64
|
+
- `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built, time-based animation effect from `@wix/motion-presets`. Refer to motion-presets rules for available presets and their options.
|
|
65
|
+
- `[FILL_MODE]` - optional. Always `'both'` with `triggerType: 'alternate'` or `'repeat'`, otherwise depends on the effect.
|
|
66
|
+
- `[INITIAL_REVERSED_BOOL]` — optional. `true` to start in the finished state so the entire effect is reversed.
|
|
67
|
+
- `[DURATION_MS]` — animation duration in milliseconds.
|
|
68
|
+
- `[EASING_FUNCTION]` — CSS easing string, or named easing from `@wix/motion`.
|
|
69
|
+
- `[DELAY_MS]` — optional delay before the effect starts, in milliseconds.
|
|
70
|
+
- `[ITERATIONS]` — optional. Number of iterations, or `Infinity` for continuous loops.
|
|
71
|
+
- `[ALTERNATE_BOOL]` — optional. `true` to alternate direction on every other iteration (within a single playback). Different from `triggerType: 'alternate'` which alternates per click.
|
|
72
|
+
- `[UNIQUE_EFFECT_ID]` — optional. String identifier used by `animationEnd` triggers for chaining, and by sequences for referencing effects from the top-level `effects` map.
|
|
289
73
|
|
|
290
74
|
---
|
|
291
75
|
|
|
292
|
-
## Rule
|
|
76
|
+
## Rule 2: transition / transitionProperties (StateEffect)
|
|
293
77
|
|
|
294
|
-
|
|
78
|
+
Use `transition` or `transitionProperties` when the click should toggle styles via DOM attribute change and CSS transitions rather than keyframe animations. Uses the `transition` CSS property. Set `stateAction` on the effect to control how the style is applied.
|
|
295
79
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
- When animating CSS properties directly
|
|
299
|
-
- For theme toggles and style switches
|
|
300
|
-
- When you need precise control over CSS transitions
|
|
301
|
-
- For simple property changes without complex keyframes
|
|
302
|
-
|
|
303
|
-
**Pattern**:
|
|
80
|
+
Use `transition` when all properties share timing. Use `transitionProperties` when each property needs independent `duration`, `delay`, or `easing`.
|
|
304
81
|
|
|
305
82
|
```typescript
|
|
306
83
|
{
|
|
307
84
|
key: '[SOURCE_KEY]',
|
|
308
85
|
trigger: 'click',
|
|
309
|
-
params: {
|
|
310
|
-
method: 'toggle' // also: 'add', 'remove', 'clear' — see full-lean.md StateParams
|
|
311
|
-
},
|
|
312
86
|
effects: [
|
|
313
87
|
{
|
|
314
88
|
key: '[TARGET_KEY]',
|
|
89
|
+
stateAction: '[STATE_ACTION]',
|
|
90
|
+
|
|
91
|
+
// --- pick ONE of the two transition forms ---
|
|
315
92
|
transition: {
|
|
316
93
|
duration: [DURATION_MS],
|
|
317
94
|
delay: [DELAY_MS],
|
|
318
95
|
easing: '[EASING_FUNCTION]',
|
|
319
96
|
styleProperties: [
|
|
320
|
-
{ name: '[
|
|
321
|
-
|
|
97
|
+
{ name: '[CSS_PROP]', value: '[VALUE]' },
|
|
98
|
+
// ... more properties
|
|
322
99
|
]
|
|
323
100
|
},
|
|
324
|
-
|
|
101
|
+
// OR (when each property needs its own timing)
|
|
102
|
+
transitionProperties: [
|
|
103
|
+
{
|
|
104
|
+
name: '[CSS_PROP]',
|
|
105
|
+
value: '[VALUE]',
|
|
106
|
+
duration: [DURATION_MS],
|
|
107
|
+
delay: [DELAY_MS],
|
|
108
|
+
easing: '[EASING_FUNCTION]'
|
|
109
|
+
},
|
|
110
|
+
// ... more properties
|
|
111
|
+
]
|
|
325
112
|
}
|
|
326
113
|
]
|
|
327
114
|
}
|
|
328
115
|
```
|
|
329
116
|
|
|
330
|
-
|
|
117
|
+
### Variables
|
|
331
118
|
|
|
332
|
-
- `[
|
|
333
|
-
- `[
|
|
334
|
-
-
|
|
119
|
+
- `[SOURCE_KEY]` / `[TARGET_KEY]` — same as Rule 1.
|
|
120
|
+
- `[STATE_ACTION]` — `stateAction` on the effect. One of:
|
|
121
|
+
- `'toggle'` — applies the style state, removes it on next click. Default.
|
|
122
|
+
- `'add'` — applies the style state. Does not remove on subsequent clicks.
|
|
123
|
+
- `'remove'` — removes a previously applied style state.
|
|
124
|
+
- `'clear'` — clears all previously applied style states. Useful for resetting multiple stacked style states at once.
|
|
125
|
+
- `[CSS_PROP]` — CSS property name as a string in camelCase format (e.g. `'backgroundColor'`, `'borderRadius'`, `'opacity'`).
|
|
126
|
+
- `[VALUE]` — target CSS value for the property.
|
|
127
|
+
- `[DURATION_MS]` — transition duration in milliseconds.
|
|
128
|
+
- `[DELAY_MS]` — optional transition delay in milliseconds.
|
|
129
|
+
- `[EASING_FUNCTION]` — CSS easing string, or named easing from `@wix/motion`.
|
|
335
130
|
|
|
336
|
-
|
|
131
|
+
---
|
|
337
132
|
|
|
338
|
-
|
|
339
|
-
{
|
|
340
|
-
key: 'theme-switcher',
|
|
341
|
-
trigger: 'click',
|
|
342
|
-
params: {
|
|
343
|
-
method: 'toggle'
|
|
344
|
-
},
|
|
345
|
-
effects: [
|
|
346
|
-
{
|
|
347
|
-
key: 'page-body',
|
|
348
|
-
transition: {
|
|
349
|
-
duration: 400,
|
|
350
|
-
easing: 'ease-in-out',
|
|
351
|
-
styleProperties: [
|
|
352
|
-
{ name: 'background-color', value: '#1a1a1a' },
|
|
353
|
-
{ name: 'color', value: '#ffffff' },
|
|
354
|
-
{ name: 'border-color', value: '#374151' },
|
|
355
|
-
{ name: '--accent-color', value: '#475137ff' } // custom CSS properties are also supported
|
|
356
|
-
]
|
|
357
|
-
},
|
|
358
|
-
effectId: 'theme-switch'
|
|
359
|
-
}
|
|
360
|
-
]
|
|
361
|
-
}
|
|
362
|
-
```
|
|
133
|
+
## Rule 3: customEffect (TimeEffect)
|
|
363
134
|
|
|
364
|
-
|
|
135
|
+
Use `customEffect` when you need imperative control over the animation (e.g. counters, canvas drawing, custom DOM manipulation, randomized behavior). The callback receives the target element and a `progress` value (0–1) driven by the animation timeline.
|
|
365
136
|
|
|
366
137
|
```typescript
|
|
367
138
|
{
|
|
368
|
-
key: '
|
|
139
|
+
key: '[SOURCE_KEY]',
|
|
369
140
|
trigger: 'click',
|
|
370
|
-
params: {
|
|
371
|
-
method: 'toggle'
|
|
372
|
-
},
|
|
373
141
|
effects: [
|
|
374
142
|
{
|
|
375
|
-
key: '
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
{ name: 'background-color', value: '#ef4444' },
|
|
381
|
-
{ name: 'color', value: '#ffffff' },
|
|
382
|
-
{ name: 'border-radius', value: '24px' },
|
|
383
|
-
{ name: 'transform', value: 'scale(1.05)' }
|
|
384
|
-
]
|
|
385
|
-
}
|
|
143
|
+
key: '[TARGET_KEY]',
|
|
144
|
+
triggerType: '[TRIGGER_TYPE]',
|
|
145
|
+
customEffect: [CUSTOM_EFFECT_CALLBACK],
|
|
146
|
+
duration: [DURATION_MS],
|
|
147
|
+
easing: '[EASING_FUNCTION]'
|
|
386
148
|
}
|
|
387
149
|
]
|
|
388
150
|
}
|
|
389
151
|
```
|
|
390
152
|
|
|
391
|
-
|
|
153
|
+
### Variables
|
|
392
154
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
params: {
|
|
398
|
-
method: 'toggle'
|
|
399
|
-
},
|
|
400
|
-
effects: [
|
|
401
|
-
{
|
|
402
|
-
key: 'interactive-card',
|
|
403
|
-
transition: {
|
|
404
|
-
duration: 250,
|
|
405
|
-
easing: 'ease-in-out',
|
|
406
|
-
styleProperties: [
|
|
407
|
-
{ name: 'background-color', value: '#f3f4f6' },
|
|
408
|
-
{ name: 'border-color', value: '#2563eb' },
|
|
409
|
-
{ name: 'box-shadow', value: '0 20px 25px rgba(0,0,0,0.15)' }
|
|
410
|
-
]
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
]
|
|
414
|
-
}
|
|
415
|
-
```
|
|
155
|
+
- `[SOURCE_KEY]` / `[TARGET_KEY]` / `[TRIGGER_TYPE]` — same as Rule 1.
|
|
156
|
+
- `[CUSTOM_EFFECT_CALLBACK]` — function with signature `(element: HTMLElement, progress: number) => void`. Called on each animation frame with target element and `progress` from 0 to 1.
|
|
157
|
+
- `[DURATION_MS]` — animation duration in milliseconds.
|
|
158
|
+
- `[EASING_FUNCTION]` — CSS easing string, or named easing from `@wix/motion`.
|
|
416
159
|
|
|
417
160
|
---
|
|
418
161
|
|
|
419
|
-
## Rule
|
|
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)
|
|
162
|
+
## Rule 4: Sequences
|
|
422
163
|
|
|
423
|
-
|
|
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**:
|
|
164
|
+
Use sequences when a click should sync/stagger animations across multiple elements. Set `triggerType` on the sequence config to control playback behavior.
|
|
431
165
|
|
|
432
166
|
```typescript
|
|
433
167
|
{
|
|
434
168
|
key: '[SOURCE_KEY]',
|
|
435
169
|
trigger: 'click',
|
|
436
|
-
params: {
|
|
437
|
-
type: 'alternate'
|
|
438
|
-
},
|
|
439
170
|
sequences: [
|
|
440
171
|
{
|
|
172
|
+
triggerType: '[TRIGGER_TYPE]',
|
|
441
173
|
offset: [OFFSET_MS],
|
|
442
174
|
offsetEasing: '[OFFSET_EASING]',
|
|
443
175
|
effects: [
|
|
444
|
-
|
|
445
|
-
|
|
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 }
|
|
176
|
+
[EFFECT_DEFINTION],
|
|
177
|
+
// .. more effects as necessary
|
|
508
178
|
]
|
|
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
|
-
|
|
530
|
-
## Advanced Patterns and Combinations
|
|
531
|
-
|
|
532
|
-
### Multi-Target Click Effects
|
|
533
|
-
|
|
534
|
-
When one click should animate multiple elements (without stagger, use `effects`; with stagger, prefer `sequences` above):
|
|
535
|
-
|
|
536
|
-
```typescript
|
|
537
|
-
{
|
|
538
|
-
key: 'master-control',
|
|
539
|
-
trigger: 'click',
|
|
540
|
-
params: {
|
|
541
|
-
type: 'alternate'
|
|
542
|
-
},
|
|
543
|
-
effects: [
|
|
544
|
-
{
|
|
545
|
-
key: 'element-1',
|
|
546
|
-
namedEffect: { type: 'FadeIn' },
|
|
547
|
-
duration: 300,
|
|
548
|
-
delay: 0,
|
|
549
|
-
fill: 'both'
|
|
550
|
-
},
|
|
551
|
-
{
|
|
552
|
-
key: 'element-2',
|
|
553
|
-
namedEffect: { type: 'SlideIn' },
|
|
554
|
-
duration: 400,
|
|
555
|
-
delay: 100,
|
|
556
|
-
fill: 'both'
|
|
557
|
-
},
|
|
558
|
-
{
|
|
559
|
-
key: 'element-3',
|
|
560
|
-
transition: {
|
|
561
|
-
duration: 200,
|
|
562
|
-
delay: 200,
|
|
563
|
-
styleProperties: [
|
|
564
|
-
{ name: 'box-shadow', value: '0 20px 25px rgba(0.2,0,0,0.15)' }
|
|
565
|
-
]
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
]
|
|
569
|
-
}
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
### Click with Animation Chaining
|
|
573
|
-
|
|
574
|
-
Using effectId for sequential animations:
|
|
575
|
-
|
|
576
|
-
```typescript
|
|
577
|
-
// First click animation
|
|
578
|
-
{
|
|
579
|
-
key: 'sequence-trigger',
|
|
580
|
-
trigger: 'click',
|
|
581
|
-
params: {
|
|
582
|
-
type: 'once'
|
|
583
|
-
},
|
|
584
|
-
effects: [
|
|
585
|
-
{
|
|
586
|
-
key: 'first-element',
|
|
587
|
-
namedEffect: { type: 'FadeIn' },
|
|
588
|
-
duration: 500,
|
|
589
|
-
effectId: 'first-fade'
|
|
590
|
-
}
|
|
591
|
-
]
|
|
592
|
-
},
|
|
593
|
-
// Chained animation
|
|
594
|
-
{
|
|
595
|
-
key: 'first-element',
|
|
596
|
-
trigger: 'animationEnd',
|
|
597
|
-
params: {
|
|
598
|
-
effectId: 'first-fade'
|
|
599
|
-
},
|
|
600
|
-
effects: [
|
|
601
|
-
{
|
|
602
|
-
key: 'second-element',
|
|
603
|
-
namedEffect: { type: 'SlideIn' },
|
|
604
|
-
duration: 400,
|
|
605
|
-
effectId: 'second-slide'
|
|
606
179
|
}
|
|
607
180
|
]
|
|
608
181
|
}
|
|
609
182
|
```
|
|
610
183
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
## Best Practices for Click Interactions
|
|
614
|
-
|
|
615
|
-
### Timing and Pattern Guidelines
|
|
616
|
-
|
|
617
|
-
1. **Keep click animations short** (100-500ms) for immediate feedback
|
|
618
|
-
2. **Use alternate pattern** for toggle states
|
|
619
|
-
3. **Use repeat pattern** for confirmation actions
|
|
620
|
-
4. **Use state pattern** for media controls
|
|
621
|
-
|
|
622
|
-
### Common Use Cases by Pattern
|
|
623
|
-
|
|
624
|
-
**Alternate Pattern**:
|
|
625
|
-
|
|
626
|
-
- Navigation menus
|
|
627
|
-
- Accordion sections
|
|
628
|
-
- Modal dialogs
|
|
629
|
-
- Sidebar toggles
|
|
630
|
-
- Dropdown menus
|
|
631
|
-
|
|
632
|
-
**State Pattern**:
|
|
633
|
-
|
|
634
|
-
- Video/audio controls
|
|
635
|
-
- Loading animations
|
|
636
|
-
- Slideshow controls
|
|
637
|
-
- Progress indicators
|
|
638
|
-
|
|
639
|
-
**Repeat Pattern**:
|
|
640
|
-
|
|
641
|
-
- Action confirmations
|
|
642
|
-
- Notification badges
|
|
643
|
-
- Button feedback
|
|
644
|
-
- Success animations
|
|
645
|
-
- Error indicators
|
|
646
|
-
|
|
647
|
-
**Transition Effects**:
|
|
184
|
+
### Variables
|
|
648
185
|
|
|
649
|
-
-
|
|
650
|
-
-
|
|
651
|
-
-
|
|
652
|
-
-
|
|
653
|
-
- CSS custom property updates
|
|
186
|
+
- `[SOURCE_KEY]` / `[TRIGGER_TYPE]` — same as Rule 1. `triggerType` is set on the sequence config, not on individual effects within the sequence.
|
|
187
|
+
- `[OFFSET_MS]` — time offset for staggering each child's animation start, in milliseconds.
|
|
188
|
+
- `[OFFSET_EASING]` — easing curve for the offset staggering distribution. Defaults to `'linear'`.
|
|
189
|
+
- `[EFFECT_DEFINTION]` — a definition of, or a reference to a time-based animation effect.
|