@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.
- 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-BfcN_rkn.mjs → index-BP07b-Y1.mjs} +1202 -751
- package/dist/index-BP07b-Y1.mjs.map +1 -0
- package/dist/index-D4orAyUu.js +18 -0
- package/dist/index-D4orAyUu.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/core/Interact.d.ts +12 -1
- package/dist/types/core/Interact.d.ts.map +1 -1
- package/dist/types/core/add.d.ts.map +1 -1
- package/dist/types/core/remove.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/docs/api/types.md +114 -0
- package/docs/examples/README.md +10 -1
- package/docs/examples/list-patterns.md +148 -0
- package/docs/guides/README.md +5 -0
- package/docs/guides/sequences.md +421 -0
- package/package.json +2 -2
- package/rules/MASTER-CLEANUP-PLAN.md +286 -0
- package/rules/click.md +124 -32
- package/rules/full-lean.md +93 -7
- package/rules/hover.md +142 -153
- package/rules/integration.md +83 -82
- package/rules/pointermove.md +32 -57
- package/rules/scroll-list.md +82 -280
- package/rules/viewenter.md +158 -253
- package/rules/viewprogress.md +139 -845
- 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/integration.md
CHANGED
|
@@ -100,6 +100,7 @@ The `InteractConfig` object defines the behavior.
|
|
|
100
100
|
type InteractConfig = {
|
|
101
101
|
interactions: Interaction[]; // Required: Array of interaction definitions
|
|
102
102
|
effects?: Record<string, Effect>; // Optional: Reusable named effects
|
|
103
|
+
sequences?: Record<string, SequenceConfig>; // Optional: Reusable sequence definitions
|
|
103
104
|
conditions?: Record<string, Condition>; // Optional: Reusable conditions (media queries)
|
|
104
105
|
};
|
|
105
106
|
```
|
|
@@ -108,22 +109,24 @@ type InteractConfig = {
|
|
|
108
109
|
|
|
109
110
|
```typescript
|
|
110
111
|
{
|
|
111
|
-
key: 'element-key',
|
|
112
|
-
trigger: 'trigger-type',
|
|
113
|
-
selector?: '.child-cls',
|
|
114
|
-
listContainer?: '.list',
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
key: 'element-key', // Matches data-interact-key
|
|
113
|
+
trigger: 'trigger-type', // e.g., 'hover', 'click'
|
|
114
|
+
selector?: '.child-cls', // Optional: CSS selector to refine target within the element
|
|
115
|
+
listContainer?: '.list', // Optional: CSS selector for a list container (enables list context)
|
|
116
|
+
listItemSelector?: '.item', // Optional: CSS selector for items within listContainer
|
|
117
|
+
params?: { ... }, // Trigger-specific parameters
|
|
118
|
+
conditions?: ['cond-id'], // Array of condition IDs
|
|
119
|
+
effects?: [ ... ], // Array of effects to apply
|
|
120
|
+
sequences?: [ ... ] // Array of sequences (coordinated staggered effects)
|
|
118
121
|
}
|
|
119
122
|
```
|
|
120
123
|
|
|
121
124
|
### Element Selection Hierarchy
|
|
122
125
|
|
|
123
|
-
1. **`listContainer` + `
|
|
124
|
-
2. **`listContainer` only**:
|
|
125
|
-
3. **`selector` only**:
|
|
126
|
-
4. **Fallback**: If
|
|
126
|
+
1. **`listContainer` + `listItemSelector`**: Selects matching items within the container as list items.
|
|
127
|
+
2. **`listContainer` only**: Targets immediate children of the container as list items.
|
|
128
|
+
3. **`selector` only**: Matches all elements within the root element (using `querySelectorAll`).
|
|
129
|
+
4. **Fallback**: If none are provided, targets the **first child** of `<interact-element>` in `web` or the root element in `react`.
|
|
127
130
|
|
|
128
131
|
## 4. Generating Critical CSS for Entrance Animations
|
|
129
132
|
|
|
@@ -134,7 +137,9 @@ Generates critical CSS styles that prevent flash-of-unstyled-content (FOUC) for
|
|
|
134
137
|
**Rules:**
|
|
135
138
|
|
|
136
139
|
- MUST be called server-side or at build time to generate static CSS.
|
|
137
|
-
- MUST set `data-interact-initial="true"` on
|
|
140
|
+
- MUST set `data-interact-initial="true"` on the `<interact-element>` whose first child should be hidden until the animation plays.
|
|
141
|
+
- Only valid when: trigger is `viewEnter` + `params.type` is `'once'` + source element and target element are the same.
|
|
142
|
+
- Do NOT use for `hover`, `click`, or `viewEnter` with `repeat`/`alternate`/`state` types.
|
|
138
143
|
|
|
139
144
|
**Usage:**
|
|
140
145
|
|
|
@@ -167,12 +172,6 @@ const html = `
|
|
|
167
172
|
`;
|
|
168
173
|
```
|
|
169
174
|
|
|
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
175
|
## 5. Triggers & Behaviors
|
|
177
176
|
|
|
178
177
|
| Trigger | Description | Key Parameters | Rules File |
|
|
@@ -186,15 +185,41 @@ const html = `
|
|
|
186
185
|
| `pointerMove` | Mouse movement | `hitArea`: 'self' (default) or 'root'; `axis`: 'x' or 'y' for keyframeEffect | `./pointermove.md` |
|
|
187
186
|
| `animationEnd` | Chaining animations | `effectId`: ID of the previous effect | -- |
|
|
188
187
|
|
|
189
|
-
##
|
|
188
|
+
## 5b. Sequences (Coordinated Stagger)
|
|
189
|
+
|
|
190
|
+
Sequences group multiple effects into a coordinated timeline with staggered timing. Instead of setting `delay` on each effect manually, define `offset` (ms between items) and `offsetEasing` (how offset is distributed).
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
### Sequence Config
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
{
|
|
196
|
+
offset: 100, // ms between consecutive effects
|
|
197
|
+
offsetEasing: 'quadIn', // easing for stagger distribution (linear, quadIn, sineOut, etc.)
|
|
198
|
+
delay: 0, // base delay before the sequence starts
|
|
199
|
+
effects: [ // effects in the sequence, applied in order
|
|
200
|
+
{ effectId: 'card-entrance', listContainer: '.card-grid' },
|
|
201
|
+
],
|
|
202
|
+
}
|
|
203
|
+
```
|
|
192
204
|
|
|
193
|
-
|
|
205
|
+
Effects in a sequence can target different elements via `key`, use `listContainer` to target list children, or reference the effects registry via `effectId`.
|
|
194
206
|
|
|
195
|
-
|
|
207
|
+
Reusable sequences can be defined in `InteractConfig.sequences` and referenced by `sequenceId`:
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
{
|
|
211
|
+
sequences: {
|
|
212
|
+
'stagger-entrance': { offset: 80, offsetEasing: 'quadIn', effects: [{ effectId: 'fade-up', listContainer: '.items' }] },
|
|
213
|
+
},
|
|
214
|
+
interactions: [
|
|
215
|
+
{ key: 'section', trigger: 'viewEnter', params: { type: 'once' }, sequences: [{ sequenceId: 'stagger-entrance' }] },
|
|
216
|
+
],
|
|
217
|
+
}
|
|
218
|
+
```
|
|
196
219
|
|
|
197
|
-
|
|
220
|
+
## 6. Named Effects & `registerEffects`
|
|
221
|
+
|
|
222
|
+
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
223
|
|
|
199
224
|
**Install:**
|
|
200
225
|
|
|
@@ -228,65 +253,6 @@ Interact.registerEffects({ FadeIn, ParallaxScroll });
|
|
|
228
253
|
}
|
|
229
254
|
```
|
|
230
255
|
|
|
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
256
|
## 7. Examples
|
|
291
257
|
|
|
292
258
|
### Basic Hover (Scale)
|
|
@@ -340,6 +306,41 @@ const config = {
|
|
|
340
306
|
};
|
|
341
307
|
```
|
|
342
308
|
|
|
309
|
+
### Staggered List Entrance (Sequence)
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
const config = {
|
|
313
|
+
interactions: [
|
|
314
|
+
{
|
|
315
|
+
key: 'card-grid',
|
|
316
|
+
trigger: 'viewEnter',
|
|
317
|
+
params: { type: 'once', threshold: 0.3 },
|
|
318
|
+
sequences: [
|
|
319
|
+
{
|
|
320
|
+
offset: 100,
|
|
321
|
+
offsetEasing: 'quadIn',
|
|
322
|
+
effects: [{ effectId: 'card-entrance', listContainer: '.card-grid' }],
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
effects: {
|
|
328
|
+
'card-entrance': {
|
|
329
|
+
duration: 500,
|
|
330
|
+
easing: 'ease-out',
|
|
331
|
+
keyframeEffect: {
|
|
332
|
+
name: 'card-fade-up',
|
|
333
|
+
keyframes: [
|
|
334
|
+
{ transform: 'translateY(40px)', opacity: 0 },
|
|
335
|
+
{ transform: 'translateY(0)', opacity: 1 },
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
fill: 'both',
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
```
|
|
343
|
+
|
|
343
344
|
### Interactive Toggle (Click)
|
|
344
345
|
|
|
345
346
|
```typescript
|
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.
|