@wix/interact 2.0.3 → 2.0.4
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/es/index.js +1 -1
- package/dist/es/react.js +2 -2
- package/dist/es/web.js +2 -2
- package/dist/index-BZL18ynN.mjs +2750 -0
- package/dist/index-BZL18ynN.mjs.map +1 -0
- package/dist/index-IaOsZpFD.js +18 -0
- package/dist/index-IaOsZpFD.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/core/Interact.d.ts +9 -1
- package/dist/types/core/Interact.d.ts.map +1 -1
- package/dist/types/core/add.d.ts.map +1 -1
- package/dist/types/handlers/animationEnd.d.ts +1 -1
- package/dist/types/handlers/animationEnd.d.ts.map +1 -1
- package/dist/types/handlers/effectHandlers.d.ts +2 -1
- package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
- package/dist/types/handlers/eventTrigger.d.ts +1 -1
- package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
- package/dist/types/handlers/viewEnter.d.ts +1 -1
- package/dist/types/handlers/viewEnter.d.ts.map +1 -1
- package/dist/types/types.d.ts +29 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/rules/MASTER-CLEANUP-PLAN.md +286 -0
- package/rules/click.md +12 -31
- package/rules/full-lean.md +26 -4
- package/rules/hover.md +68 -153
- package/rules/integration.md +17 -85
- package/rules/pointermove.md +32 -57
- package/rules/scroll-list.md +82 -280
- package/rules/viewenter.md +65 -90
- package/rules/viewprogress.md +139 -845
- package/dist/index-BfcN_rkn.mjs +0 -2338
- package/dist/index-BfcN_rkn.mjs.map +0 -1
- package/dist/index-HXLBEIjG.js +0 -18
- package/dist/index-HXLBEIjG.js.map +0 -1
package/rules/hover.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Hover Trigger Rules
|
|
1
|
+
# Hover Trigger Rules for @wix/interact
|
|
2
2
|
|
|
3
3
|
This document contains rules for generating hover trigger interactions in `@wix/interact`. These rules cover all hover behavior patterns and common use cases.
|
|
4
4
|
|
|
@@ -10,11 +10,11 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
{
|
|
13
|
-
key: '[
|
|
13
|
+
key: '[SOURCE_KEY]',
|
|
14
14
|
trigger: 'hover',
|
|
15
15
|
effects: [
|
|
16
16
|
{
|
|
17
|
-
key: '[
|
|
17
|
+
key: '[TARGET_KEY]',
|
|
18
18
|
[EFFECT_TYPE]: [EFFECT_DEFINITION],
|
|
19
19
|
fill: 'both',
|
|
20
20
|
duration: [DURATION_MS],
|
|
@@ -26,8 +26,8 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
26
26
|
|
|
27
27
|
**Variables**:
|
|
28
28
|
|
|
29
|
-
- `[
|
|
30
|
-
- `[
|
|
29
|
+
- `[SOURCE_KEY]`: Unique identifier for hoverable element. Should equal the value of the `data-interact-key` attribute on the wrapping `<interact-element>`.
|
|
30
|
+
- `[TARGET_KEY]`: Unique identifier for animated element (can be same as `[SOURCE_KEY]` for self-targeting, or different for cross-targeting).
|
|
31
31
|
- `[EFFECT_TYPE]`: Either `namedEffect` or `keyframeEffect`
|
|
32
32
|
- `[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)' }] })
|
|
33
33
|
- `[DURATION_MS]`: Animation duration in milliseconds (typically 200-500ms for micro-interactions)
|
|
@@ -38,7 +38,7 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
38
38
|
|
|
39
39
|
- `DURATION_MS`: 300 (for micro-interactions)
|
|
40
40
|
- `EASING_FUNCTION`: 'ease-out' (for smooth feel)
|
|
41
|
-
- `
|
|
41
|
+
- `[TARGET_KEY]`: Same as `[SOURCE_KEY]` for self-targeting
|
|
42
42
|
|
|
43
43
|
**Common Use Cases**:
|
|
44
44
|
|
|
@@ -93,26 +93,25 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
93
93
|
}
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
## Rule 2: Hover
|
|
96
|
+
## Rule 2: Hover Alternate Animations (namedEffect / keyframeEffect)
|
|
97
97
|
|
|
98
|
-
**Purpose**:
|
|
98
|
+
**Purpose**: Hover interactions that play forward on mouse enter and reverse on mouse leave (`type: 'alternate'`).
|
|
99
99
|
|
|
100
100
|
**Pattern**:
|
|
101
101
|
|
|
102
102
|
```typescript
|
|
103
103
|
{
|
|
104
|
-
key: '[
|
|
104
|
+
key: '[SOURCE_KEY]',
|
|
105
105
|
trigger: 'hover',
|
|
106
106
|
params: {
|
|
107
107
|
type: 'alternate'
|
|
108
108
|
},
|
|
109
109
|
effects: [
|
|
110
110
|
{
|
|
111
|
-
key: '[
|
|
112
|
-
namedEffect:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
111
|
+
key: '[TARGET_KEY]',
|
|
112
|
+
// Use namedEffect OR keyframeEffect:
|
|
113
|
+
namedEffect: { type: '[NAMED_EFFECT_TYPE]' },
|
|
114
|
+
// keyframeEffect: { name: '[EFFECT_NAME]', keyframes: [{ ... }, { ... }] },
|
|
116
115
|
fill: 'both',
|
|
117
116
|
reversed: [REVERSED_BOOL],
|
|
118
117
|
duration: [DURATION_MS],
|
|
@@ -124,143 +123,56 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
124
123
|
|
|
125
124
|
**Variables**:
|
|
126
125
|
|
|
127
|
-
- `[REVERSED_BOOL]`: Optional
|
|
128
|
-
- `[NAMED_EFFECT_TYPE]`:
|
|
129
|
-
- `
|
|
126
|
+
- `[REVERSED_BOOL]`: Optional. `true` to reverse the enter direction (mouse enter plays backwards, leave plays forwards).
|
|
127
|
+
- `[NAMED_EFFECT_TYPE]`: Pre-built effect from `@wix/motion-presets`. Available hover presets:
|
|
128
|
+
- Size: `ExpandIn`, `Pulse`, `GrowIn`
|
|
129
|
+
- Fade/Blur: `FadeIn`, `Flash`, `BlurIn`
|
|
130
|
+
- Translate: `SlideIn`, `GlideIn`, `FloatIn`, `BounceIn`, `GlitchIn`
|
|
131
|
+
- Rotate: `SpinIn`, `TiltIn`, `ArcIn`, `TurnIn`, `FlipIn`, `Spin`, `Swing`
|
|
132
|
+
- Attention: `Bounce`, `DropIn`, `Rubber`, `Jello`, `Cross`, `Wiggle`, `Poke`
|
|
130
133
|
- Other variables same as Rule 1
|
|
131
134
|
|
|
132
|
-
**
|
|
133
|
-
|
|
134
|
-
- **Size Changes**: `ExpandIn`, `Pulse`, `GrowIn`
|
|
135
|
-
- **Opacity/Blur Changes**: `FadeIn`, `Flash`, `BlurIn`
|
|
136
|
-
- **Translation Effects**: `SlideIn`, `GlideIn`, `FloatIn`, `BounceIn`, `GlitchIn`
|
|
137
|
-
- **Rotation Effects**: `SpinIn`, `TiltIn`, `ArcIn`, `TurnIn`, `FlipIn`, `Spin`, `Swing`
|
|
138
|
-
- **Special Attention Effects**: `Bounce`, `DropIn`, `Rubber`, `Jello`, `Cross`, `Wiggle`, `Poke`
|
|
139
|
-
|
|
140
|
-
**Important**: Spatial effects that change the hit-area considerably (translation, rotation) should use different source and target keys to avoid unwanted flickering on hover enter/leave.
|
|
135
|
+
**Important**: Spatial effects (translation, rotation) that change the hit-area considerably should use different source and target keys to avoid flickering on enter/leave.
|
|
141
136
|
|
|
142
137
|
**Default Values**:
|
|
143
138
|
|
|
144
|
-
- `
|
|
145
|
-
- `DURATION_MS`: 250
|
|
139
|
+
- `DURATION_MS`: 250–300
|
|
146
140
|
- `EASING_FUNCTION`: 'ease-out'
|
|
147
141
|
|
|
148
|
-
**Example
|
|
142
|
+
**Example — namedEffect (card scale)**:
|
|
149
143
|
|
|
150
144
|
```typescript
|
|
151
|
-
// Card scale effect
|
|
152
145
|
{
|
|
153
146
|
key: 'feature-card',
|
|
154
147
|
trigger: 'hover',
|
|
155
|
-
params: {
|
|
156
|
-
type: 'alternate'
|
|
157
|
-
},
|
|
148
|
+
params: { type: 'alternate' },
|
|
158
149
|
effects: [
|
|
159
150
|
{
|
|
160
151
|
key: 'feature-card',
|
|
161
|
-
namedEffect: {
|
|
162
|
-
type: 'Pulse'
|
|
163
|
-
},
|
|
152
|
+
namedEffect: { type: 'Pulse' },
|
|
164
153
|
fill: 'both',
|
|
165
154
|
duration: 250,
|
|
166
155
|
easing: 'ease-out'
|
|
167
156
|
}
|
|
168
157
|
]
|
|
169
158
|
}
|
|
170
|
-
|
|
171
|
-
// Icon rotation effect (different source/target to avoid flickering)
|
|
172
|
-
{
|
|
173
|
-
key: 'button',
|
|
174
|
-
trigger: 'hover',
|
|
175
|
-
params: {
|
|
176
|
-
type: 'alternate'
|
|
177
|
-
},
|
|
178
|
-
effects: [
|
|
179
|
-
{
|
|
180
|
-
key: 'button-icon',
|
|
181
|
-
namedEffect: {
|
|
182
|
-
type: 'SpinIn',
|
|
183
|
-
direction: 'clockwise'
|
|
184
|
-
},
|
|
185
|
-
fill: 'both',
|
|
186
|
-
duration: 200,
|
|
187
|
-
easing: 'ease-out'
|
|
188
|
-
}
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Rule 3: Hover Interactions with Alternate Pattern
|
|
194
|
-
|
|
195
|
-
**Purpose**: Generate hover interactions that play forward on mouse enter and reverse on mouse leave
|
|
196
|
-
|
|
197
|
-
**Pattern**:
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
{
|
|
201
|
-
key: '[SOURCE_IDENTIFIER]',
|
|
202
|
-
trigger: 'hover',
|
|
203
|
-
params: {
|
|
204
|
-
type: 'alternate'
|
|
205
|
-
},
|
|
206
|
-
effects: [
|
|
207
|
-
{
|
|
208
|
-
key: '[TARGET_IDENTIFIER]',
|
|
209
|
-
keyframeEffect: {
|
|
210
|
-
name: '[UNIQUE_KEYFRAME_EFFECT_NAME]',
|
|
211
|
-
keyframes: [
|
|
212
|
-
{ [PROPERTY_1]: '[START_VALUE]', [PROPERTY_2]: '[START_VALUE]' },
|
|
213
|
-
{ [PROPERTY_1]: '[END_VALUE]', [PROPERTY_2]: '[END_VALUE]' }
|
|
214
|
-
]
|
|
215
|
-
},
|
|
216
|
-
fill: 'both',
|
|
217
|
-
duration: [DURATION_MS],
|
|
218
|
-
easing: '[EASING_FUNCTION]'
|
|
219
|
-
}
|
|
220
|
-
]
|
|
221
|
-
}
|
|
222
159
|
```
|
|
223
160
|
|
|
224
|
-
**
|
|
225
|
-
|
|
226
|
-
- `[UNIQUE_KEYFRAME_EFFECT_NAME]`: unique name for the keyframeEffect.
|
|
227
|
-
- `[PROPERTY_N]`: animatable CSS property.
|
|
228
|
-
- `[START/END_VALUE]`: values for the animated CSS properties in the start/end frame.
|
|
229
|
-
- Other variables same as Rule 1
|
|
230
|
-
|
|
231
|
-
**Best Properties for Hover Effects**:
|
|
232
|
-
|
|
233
|
-
- `transform`: scale, translate, rotate transformations
|
|
234
|
-
- `opacity`: fade effects
|
|
235
|
-
- `box-shadow`: elevation changes
|
|
236
|
-
- `filter`: blur, brightness, hue-rotate
|
|
237
|
-
- `background-color`: color transitions
|
|
238
|
-
- Spatial effects that change the hit-area of the animated element considerably (e.g. Translation effects, Rotation effects, etc.) should have different source and target to avoid unwanted flickering.
|
|
239
|
-
|
|
240
|
-
**Default Values**:
|
|
241
|
-
|
|
242
|
-
- `type`: 'alternate'
|
|
243
|
-
- `DURATION_MS`: 300
|
|
244
|
-
- `EASING_FUNCTION`: 'ease-out'
|
|
245
|
-
|
|
246
|
-
**Example Generations**:
|
|
161
|
+
**Example — keyframeEffect (card lift)**:
|
|
247
162
|
|
|
248
163
|
```typescript
|
|
249
|
-
// Card hover with multiple properties
|
|
250
164
|
{
|
|
251
165
|
key: 'portfolio-item',
|
|
252
166
|
trigger: 'hover',
|
|
253
|
-
params: {
|
|
254
|
-
type: 'alternate'
|
|
255
|
-
},
|
|
167
|
+
params: { type: 'alternate' },
|
|
256
168
|
effects: [
|
|
257
169
|
{
|
|
258
170
|
key: 'portfolio-item',
|
|
259
171
|
keyframeEffect: {
|
|
260
|
-
name: 'portfolio',
|
|
172
|
+
name: 'portfolio-lift',
|
|
261
173
|
keyframes: [
|
|
262
|
-
{ transform: 'translateY(0)', boxShadow: '0 4px 6px rgba(0,0,0,0.1)'
|
|
263
|
-
{ transform: 'translateY(-8px)', boxShadow: '0 20px 25px rgba(0,0,0,0.15)'
|
|
174
|
+
{ transform: 'translateY(0)', boxShadow: '0 4px 6px rgba(0,0,0,0.1)' },
|
|
175
|
+
{ transform: 'translateY(-8px)', boxShadow: '0 20px 25px rgba(0,0,0,0.15)' }
|
|
264
176
|
]
|
|
265
177
|
},
|
|
266
178
|
fill: 'both',
|
|
@@ -269,33 +181,9 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
269
181
|
}
|
|
270
182
|
]
|
|
271
183
|
}
|
|
272
|
-
|
|
273
|
-
// Image overlay reveal
|
|
274
|
-
{
|
|
275
|
-
key: 'gallery-image',
|
|
276
|
-
trigger: 'hover',
|
|
277
|
-
params: {
|
|
278
|
-
type: 'alternate'
|
|
279
|
-
},
|
|
280
|
-
effects: [
|
|
281
|
-
{
|
|
282
|
-
key: 'image-overlay',
|
|
283
|
-
keyframeEffect: {
|
|
284
|
-
name: 'image-overlay-slide',
|
|
285
|
-
keyframes: [
|
|
286
|
-
{ opacity: '0', transform: 'translateY(100%)' },
|
|
287
|
-
{ opacity: '1', transform: 'translateY(0)' }
|
|
288
|
-
]
|
|
289
|
-
},
|
|
290
|
-
fill: 'both',
|
|
291
|
-
duration: 250,
|
|
292
|
-
easing: 'ease-out'
|
|
293
|
-
}
|
|
294
|
-
]
|
|
295
|
-
}
|
|
296
184
|
```
|
|
297
185
|
|
|
298
|
-
## Rule
|
|
186
|
+
## Rule 3: Hover Interactions with Repeat Pattern
|
|
299
187
|
|
|
300
188
|
**Purpose**: Generate hover interactions that restart animation each time mouse enters
|
|
301
189
|
|
|
@@ -303,14 +191,14 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
303
191
|
|
|
304
192
|
```typescript
|
|
305
193
|
{
|
|
306
|
-
key: '[
|
|
194
|
+
key: '[SOURCE_KEY]',
|
|
307
195
|
trigger: 'hover',
|
|
308
196
|
params: {
|
|
309
197
|
type: 'repeat'
|
|
310
198
|
},
|
|
311
199
|
effects: [
|
|
312
200
|
{
|
|
313
|
-
key: '[
|
|
201
|
+
key: '[TARGET_KEY]',
|
|
314
202
|
[EFFECT_TYPE]: [EFFECT_DEFINITION],
|
|
315
203
|
duration: [DURATION_MS],
|
|
316
204
|
easing: '[EASING_FUNCTION]'
|
|
@@ -384,7 +272,7 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
384
272
|
}
|
|
385
273
|
```
|
|
386
274
|
|
|
387
|
-
## Rule
|
|
275
|
+
## Rule 4: Hover Interactions with Play/Pause Pattern
|
|
388
276
|
|
|
389
277
|
**Purpose**: Generate hover interactions that pause/resume on hover (state-based control)
|
|
390
278
|
|
|
@@ -392,14 +280,14 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
392
280
|
|
|
393
281
|
```typescript
|
|
394
282
|
{
|
|
395
|
-
key: '[
|
|
283
|
+
key: '[SOURCE_KEY]',
|
|
396
284
|
trigger: 'hover',
|
|
397
285
|
params: {
|
|
398
286
|
type: 'state'
|
|
399
287
|
},
|
|
400
288
|
effects: [
|
|
401
289
|
{
|
|
402
|
-
key: '[
|
|
290
|
+
key: '[TARGET_KEY]',
|
|
403
291
|
[EFFECT_TYPE]: [EFFECT_DEFINITION],
|
|
404
292
|
duration: [DURATION_MS],
|
|
405
293
|
iterations: Infinity,
|
|
@@ -475,7 +363,7 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
475
363
|
}
|
|
476
364
|
```
|
|
477
365
|
|
|
478
|
-
## Rule
|
|
366
|
+
## Rule 5: Multi-Target Hover Effects
|
|
479
367
|
|
|
480
368
|
**Purpose**: Generate hover interactions that affect multiple elements from a single source
|
|
481
369
|
|
|
@@ -483,7 +371,7 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
483
371
|
|
|
484
372
|
```typescript
|
|
485
373
|
{
|
|
486
|
-
key: '[
|
|
374
|
+
key: '[SOURCE_KEY]',
|
|
487
375
|
trigger: 'hover',
|
|
488
376
|
params: {
|
|
489
377
|
type: '[BEHAVIOR_TYPE]'
|
|
@@ -512,7 +400,7 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
512
400
|
**Variables**:
|
|
513
401
|
|
|
514
402
|
- `[BEHAVIOR_TYPE]`: type of behavior for the effect. use `alternate`, `repeat`, or `state` according to the previous rules.
|
|
515
|
-
- `[FILL_N]`: Optional fill value for the Nth effect - same
|
|
403
|
+
- `[FILL_N]`: Optional fill value for the Nth effect - same as CSS animation-fill-mode (e.g. 'both', 'forwards', 'backwards').
|
|
516
404
|
- `[REVERSED_BOOL_N]`: Same as `[REVERSED_BOOL]` from Rule 2 only for the Nth effect.
|
|
517
405
|
- `[DURATION_N]`: Same as `[DURATION_MS]` from Rule 1 only for the Nth effect.
|
|
518
406
|
- `[DELAY_N]`: Delay in milliseconds of the Nth effect.
|
|
@@ -598,10 +486,9 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
598
486
|
|
|
599
487
|
## Best Practices for Hover Rules
|
|
600
488
|
|
|
601
|
-
###
|
|
489
|
+
### Timing and Pattern Guidelines
|
|
602
490
|
|
|
603
491
|
1. **Keep durations short** (100-400ms) for responsiveness
|
|
604
|
-
2. **Avoid animating layout properties**: width, height, margin, padding
|
|
605
492
|
|
|
606
493
|
### User Experience Guidelines
|
|
607
494
|
|
|
@@ -623,3 +510,31 @@ This document contains rules for generating hover trigger interactions in `@wix/
|
|
|
623
510
|
- **Interactive elements**: 'ease-in-out' (smooth both ways)
|
|
624
511
|
- **Attention effects**: 'ease-in-out' (natural feel)
|
|
625
512
|
- **Continuous motion**: 'linear' (consistent speed)
|
|
513
|
+
|
|
514
|
+
## Accessibility
|
|
515
|
+
|
|
516
|
+
Use `@wix/interact`'s `conditions` API to skip hover animations for users who prefer reduced motion. Define a `prefers-motion` condition and reference it on any interaction that should be suppressed:
|
|
517
|
+
|
|
518
|
+
```typescript
|
|
519
|
+
{
|
|
520
|
+
conditions: {
|
|
521
|
+
'prefers-motion': { type: 'media', predicate: '(prefers-reduced-motion: no-preference)' }
|
|
522
|
+
},
|
|
523
|
+
interactions: [
|
|
524
|
+
{
|
|
525
|
+
key: 'card',
|
|
526
|
+
trigger: 'hover',
|
|
527
|
+
conditions: ['prefers-motion'], // skipped when reduced-motion is preferred
|
|
528
|
+
effects: [/* ... */]
|
|
529
|
+
}
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
For pointer-primary devices only, also consider adding a `hover-capable` condition:
|
|
535
|
+
|
|
536
|
+
```typescript
|
|
537
|
+
'hover-capable': { type: 'media', predicate: '(hover: hover)' }
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
Use `trigger: 'interest'` instead of `'hover'` to also handle keyboard focus, which is the accessible equivalent of hover.
|
package/rules/integration.md
CHANGED
|
@@ -108,22 +108,23 @@ type InteractConfig = {
|
|
|
108
108
|
|
|
109
109
|
```typescript
|
|
110
110
|
{
|
|
111
|
-
key: 'element-key',
|
|
112
|
-
trigger: 'trigger-type',
|
|
113
|
-
selector?: '.child-cls',
|
|
114
|
-
listContainer?: '.list',
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
key: 'element-key', // Matches data-interact-key
|
|
112
|
+
trigger: 'trigger-type', // e.g., 'hover', 'click'
|
|
113
|
+
selector?: '.child-cls', // Optional: CSS selector to refine target within the element
|
|
114
|
+
listContainer?: '.list', // Optional: CSS selector for a list container (enables list context)
|
|
115
|
+
listItemSelector?: '.item', // Optional: CSS selector for items within listContainer
|
|
116
|
+
params?: { ... }, // Trigger-specific parameters
|
|
117
|
+
conditions?: ['cond-id'], // Array of condition IDs
|
|
118
|
+
effects: [ ... ] // Array of effects to apply
|
|
118
119
|
}
|
|
119
120
|
```
|
|
120
121
|
|
|
121
122
|
### Element Selection Hierarchy
|
|
122
123
|
|
|
123
|
-
1. **`listContainer` + `
|
|
124
|
-
2. **`listContainer` only**:
|
|
125
|
-
3. **`selector` only**:
|
|
126
|
-
4. **Fallback**: If
|
|
124
|
+
1. **`listContainer` + `listItemSelector`**: Selects matching items within the container as list items.
|
|
125
|
+
2. **`listContainer` only**: Targets immediate children of the container as list items.
|
|
126
|
+
3. **`selector` only**: Matches all elements within the root element (using `querySelectorAll`).
|
|
127
|
+
4. **Fallback**: If none are provided, targets the **first child** of `<interact-element>` in `web` or the root element in `react`.
|
|
127
128
|
|
|
128
129
|
## 4. Generating Critical CSS for Entrance Animations
|
|
129
130
|
|
|
@@ -134,7 +135,9 @@ Generates critical CSS styles that prevent flash-of-unstyled-content (FOUC) for
|
|
|
134
135
|
**Rules:**
|
|
135
136
|
|
|
136
137
|
- MUST be called server-side or at build time to generate static CSS.
|
|
137
|
-
- MUST set `data-interact-initial="true"` on
|
|
138
|
+
- MUST set `data-interact-initial="true"` on the `<interact-element>` whose first child should be hidden until the animation plays.
|
|
139
|
+
- Only valid when: trigger is `viewEnter` + `params.type` is `'once'` + source element and target element are the same.
|
|
140
|
+
- Do NOT use for `hover`, `click`, or `viewEnter` with `repeat`/`alternate`/`state` types.
|
|
138
141
|
|
|
139
142
|
**Usage:**
|
|
140
143
|
|
|
@@ -167,12 +170,6 @@ const html = `
|
|
|
167
170
|
`;
|
|
168
171
|
```
|
|
169
172
|
|
|
170
|
-
**When to Use:**
|
|
171
|
-
|
|
172
|
-
- For elements with an entrance effect that is triggered with `viewEnter`
|
|
173
|
-
- To prevent elements from being visible before their entrance animation plays
|
|
174
|
-
- For server-side rendering (SSR) or static site generation (SSG) scenarios
|
|
175
|
-
|
|
176
173
|
## 5. Triggers & Behaviors
|
|
177
174
|
|
|
178
175
|
| Trigger | Description | Key Parameters | Rules File |
|
|
@@ -186,15 +183,9 @@ const html = `
|
|
|
186
183
|
| `pointerMove` | Mouse movement | `hitArea`: 'self' (default) or 'root'; `axis`: 'x' or 'y' for keyframeEffect | `./pointermove.md` |
|
|
187
184
|
| `animationEnd` | Chaining animations | `effectId`: ID of the previous effect | -- |
|
|
188
185
|
|
|
189
|
-
## 6. Effects &
|
|
190
|
-
|
|
191
|
-
Effects define _what_ happens. They can be inline or referenced by ID.
|
|
192
|
-
|
|
193
|
-
### Effect Types
|
|
194
|
-
|
|
195
|
-
#### 1. Named Effects (Pre-built effect library)>
|
|
186
|
+
## 6. Named Effects & `registerEffects`
|
|
196
187
|
|
|
197
|
-
|
|
188
|
+
To use `namedEffect` presets from `@wix/motion-presets`, register them before calling `Interact.create`. For full effect type syntax (`keyframeEffect`, `customEffect`, `TransitionEffect`, `ScrubEffect`), see `full-lean.md`.
|
|
198
189
|
|
|
199
190
|
**Install:**
|
|
200
191
|
|
|
@@ -228,65 +219,6 @@ Interact.registerEffects({ FadeIn, ParallaxScroll });
|
|
|
228
219
|
}
|
|
229
220
|
```
|
|
230
221
|
|
|
231
|
-
#### 2. Keyframe Effects (Custom)
|
|
232
|
-
|
|
233
|
-
Define explicit Web Animations API-like keyframes.
|
|
234
|
-
|
|
235
|
-
```typescript
|
|
236
|
-
{
|
|
237
|
-
keyframeEffect: {
|
|
238
|
-
name: 'custom-slide',
|
|
239
|
-
keyframes: [
|
|
240
|
-
{ transform: 'translateY(20px)', opacity: 0 },
|
|
241
|
-
{ transform: 'translateY(0)', opacity: 1 }
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
duration: 500
|
|
245
|
-
}
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### 3. Transition Effects
|
|
249
|
-
|
|
250
|
-
Smoothly transition CSS properties.
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
{
|
|
254
|
-
transition: {
|
|
255
|
-
duration: 300,
|
|
256
|
-
styleProperties: [{ name: 'backgroundColor', value: 'red' }]
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
#### 4. Scroll Effects
|
|
262
|
-
|
|
263
|
-
Used with `viewProgress`, linked to scroll progress while element is inside viewport.
|
|
264
|
-
|
|
265
|
-
```typescript
|
|
266
|
-
{
|
|
267
|
-
keyframeEffect: { ... },
|
|
268
|
-
rangeStart: { name: 'cover', offset: { value: 0, unit: 'percentage' } },
|
|
269
|
-
rangeEnd: { name: 'cover', offset: { value: 100, unit: 'percentage' } },
|
|
270
|
-
fill: 'both'
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
#### 5. Mouse Effects
|
|
275
|
-
|
|
276
|
-
Used with `pointerMove`, linked to mouse progress while moving over an element.
|
|
277
|
-
|
|
278
|
-
```typescript
|
|
279
|
-
{
|
|
280
|
-
namedEffect: { type: 'Track3DMouse' },
|
|
281
|
-
centeredToTarget: true
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### Targeting
|
|
286
|
-
|
|
287
|
-
- **Self**: Omit `key` in the effect to target the trigger element. If using `selector` for trigger, also specify it again for the effect target.
|
|
288
|
-
- **Cross-Targeting**: Specify a different `key` and/or `selector` in the effect to animate a different element.
|
|
289
|
-
|
|
290
222
|
## 7. Examples
|
|
291
223
|
|
|
292
224
|
### Basic Hover (Scale)
|
package/rules/pointermove.md
CHANGED
|
@@ -1142,6 +1142,16 @@ This example shows a pointer-driven slider where the X position controls both a
|
|
|
1142
1142
|
},
|
|
1143
1143
|
fill: 'both',
|
|
1144
1144
|
},
|
|
1145
|
+
'indicator-effect': {
|
|
1146
|
+
keyframeEffect: {
|
|
1147
|
+
name: 'indicator-fade-scale',
|
|
1148
|
+
keyframes: [
|
|
1149
|
+
{ opacity: '0.3', transform: 'scale(0.8)' },
|
|
1150
|
+
{ opacity: '1', transform: 'scale(1)' },
|
|
1151
|
+
],
|
|
1152
|
+
},
|
|
1153
|
+
fill: 'both',
|
|
1154
|
+
},
|
|
1145
1155
|
},
|
|
1146
1156
|
}
|
|
1147
1157
|
```
|
|
@@ -1223,44 +1233,29 @@ X axis controls `scaleX`, Y axis controls `scaleY`.
|
|
|
1223
1233
|
|
|
1224
1234
|
### Responsive Pointer Effects
|
|
1225
1235
|
|
|
1226
|
-
|
|
1236
|
+
`pointerMove` only fires on pointer-capable devices, but touch users still visit the page. Use the `conditions` config map to define device/motion guards — condition IDs are arbitrary strings you define, matched against the media query predicates you provide.
|
|
1227
1237
|
|
|
1228
1238
|
```typescript
|
|
1229
1239
|
{
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1240
|
+
conditions: {
|
|
1241
|
+
// Only run pointer effects on devices that support hover (non-touch)
|
|
1242
|
+
'supports-hover': { type: 'media', predicate: '(hover: hover)' },
|
|
1243
|
+
// Suppress animations for users who prefer reduced motion
|
|
1244
|
+
'prefers-motion': { type: 'media', predicate: '(prefers-reduced-motion: no-preference)' },
|
|
1235
1245
|
},
|
|
1236
|
-
|
|
1237
|
-
{
|
|
1238
|
-
key: 'responsive-element',
|
|
1239
|
-
namedEffect: {
|
|
1240
|
-
type: 'Tilt3DMouse',
|
|
1241
|
-
angle: 20,
|
|
1242
|
-
perspective: 800
|
|
1243
|
-
},
|
|
1244
|
-
centeredToTarget: true
|
|
1245
|
-
}
|
|
1246
|
-
]
|
|
1247
|
-
},
|
|
1248
|
-
// Simplified version for touch devices
|
|
1249
|
-
{
|
|
1250
|
-
key: 'responsive-element',
|
|
1251
|
-
trigger: 'pointerMove',
|
|
1252
|
-
conditions: ['touch-device'],
|
|
1253
|
-
params: {
|
|
1254
|
-
hitArea: 'self'
|
|
1255
|
-
},
|
|
1256
|
-
effects: [
|
|
1246
|
+
interactions: [
|
|
1257
1247
|
{
|
|
1258
1248
|
key: 'responsive-element',
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1249
|
+
trigger: 'pointerMove',
|
|
1250
|
+
conditions: ['supports-hover', 'prefers-motion'],
|
|
1251
|
+
params: { hitArea: 'self' },
|
|
1252
|
+
effects: [
|
|
1253
|
+
{
|
|
1254
|
+
key: 'responsive-element',
|
|
1255
|
+
namedEffect: { type: 'Tilt3DMouse', angle: 20, perspective: 800 },
|
|
1256
|
+
centeredToTarget: true
|
|
1257
|
+
}
|
|
1258
|
+
]
|
|
1264
1259
|
}
|
|
1265
1260
|
]
|
|
1266
1261
|
}
|
|
@@ -1374,12 +1369,11 @@ Controlling movement direction for specific design needs:
|
|
|
1374
1369
|
|
|
1375
1370
|
### Performance Guidelines
|
|
1376
1371
|
|
|
1377
|
-
1. **
|
|
1378
|
-
2. **
|
|
1379
|
-
3. **
|
|
1380
|
-
4. **
|
|
1381
|
-
5. **
|
|
1382
|
-
6. **Prefer `namedEffect` over `customEffect`** - named effects are optimized for GPU acceleration
|
|
1372
|
+
1. **Limit simultaneous pointer effects** - too many can cause performance issues
|
|
1373
|
+
2. **Test on various devices** - pointer sensitivity varies across hardware
|
|
1374
|
+
3. **Cache DOM queries outside `customEffect` callbacks** - avoid repeated `querySelector` calls inside the callback
|
|
1375
|
+
4. **Use `requestAnimationFrame` sparingly** - the library already handles frame timing
|
|
1376
|
+
5. **Prefer `namedEffect` over `customEffect`** - named effects are optimized for GPU acceleration
|
|
1383
1377
|
|
|
1384
1378
|
### Hit Area Guidelines
|
|
1385
1379
|
|
|
@@ -1397,20 +1391,6 @@ Controlling movement direction for specific design needs:
|
|
|
1397
1391
|
4. **Consider responsive design** when setting centering
|
|
1398
1392
|
5. **Centering affects how progress.x/y map to element position**
|
|
1399
1393
|
|
|
1400
|
-
### User Experience Guidelines
|
|
1401
|
-
|
|
1402
|
-
1. **Keep pointer effects subtle** to avoid overwhelming users
|
|
1403
|
-
2. **Ensure effects enhance rather than distract** from content
|
|
1404
|
-
3. **Provide visual feedback** that feels natural and responsive
|
|
1405
|
-
4. **Test with actual users** to validate interaction quality
|
|
1406
|
-
|
|
1407
|
-
### Accessibility Considerations
|
|
1408
|
-
|
|
1409
|
-
1. **Respect `prefers-reduced-motion`** for all pointer animations
|
|
1410
|
-
2. **Ensure touch device compatibility** with appropriate alternatives
|
|
1411
|
-
3. **Don't rely solely on pointer effects** for important interactions
|
|
1412
|
-
4. **Provide keyboard alternatives** for interactive elements
|
|
1413
|
-
|
|
1414
1394
|
### Common Use Cases by Pattern
|
|
1415
1395
|
|
|
1416
1396
|
**Single Element 3D Effects (Rule 1)** - `namedEffect`:
|
|
@@ -1512,7 +1492,6 @@ Controlling movement direction for specific design needs:
|
|
|
1512
1492
|
**customEffect not updating smoothly**:
|
|
1513
1493
|
|
|
1514
1494
|
- Add `transitionDuration` and `transitionEasing` for smoother transitions
|
|
1515
|
-
- Ensure style changes use transform/opacity for GPU acceleration
|
|
1516
1495
|
- Avoid expensive calculations inside the callback
|
|
1517
1496
|
- Consider debouncing complex logic
|
|
1518
1497
|
|
|
@@ -1551,7 +1530,3 @@ Controlling movement direction for specific design needs:
|
|
|
1551
1530
|
| Custom physics | `customEffect` | Full control over calculations |
|
|
1552
1531
|
| Velocity-based effects | `customEffect` | Access to `progress.v` |
|
|
1553
1532
|
| Grid/particle systems | `customEffect` | Can manipulate many elements |
|
|
1554
|
-
|
|
1555
|
-
---
|
|
1556
|
-
|
|
1557
|
-
These rules provide comprehensive coverage for PointerMove trigger interactions in `@wix/interact`, supporting all hit area configurations, centering options, named effect types, keyframe effects, composite animations, and custom effect patterns.
|