@wix/interact 2.5.5 → 2.5.7

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 (61) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/react.js +1 -1
  4. package/dist/cjs/web.js +1 -1
  5. package/dist/es/index.js +1 -1
  6. package/dist/es/react.js +2 -2
  7. package/dist/es/web.js +2 -2
  8. package/dist/index-Bt4pzwx1.js +21 -0
  9. package/dist/index-Bt4pzwx1.js.map +1 -0
  10. package/dist/index-C-q7gc5a.mjs +3565 -0
  11. package/dist/index-C-q7gc5a.mjs.map +1 -0
  12. package/dist/tsconfig.build.tsbuildinfo +1 -1
  13. package/dist/types/core/Interact.d.ts +10 -1
  14. package/dist/types/core/Interact.d.ts.map +1 -1
  15. package/dist/types/core/InteractionController.d.ts +3 -1
  16. package/dist/types/core/InteractionController.d.ts.map +1 -1
  17. package/dist/types/core/add.d.ts.map +1 -1
  18. package/dist/types/core/css.d.ts +12 -4
  19. package/dist/types/core/css.d.ts.map +1 -1
  20. package/dist/types/core/cssUtils.d.ts.map +1 -1
  21. package/dist/types/core/resolvers.d.ts +2 -2
  22. package/dist/types/core/resolvers.d.ts.map +1 -1
  23. package/dist/types/types/config.d.ts +3 -2
  24. package/dist/types/types/config.d.ts.map +1 -1
  25. package/dist/types/types/controller.d.ts +5 -0
  26. package/dist/types/types/controller.d.ts.map +1 -1
  27. package/dist/types/types/css.d.ts +15 -1
  28. package/dist/types/types/css.d.ts.map +1 -1
  29. package/dist/types/types/effects.d.ts +2 -1
  30. package/dist/types/types/effects.d.ts.map +1 -1
  31. package/dist/types/types/external.d.ts +2 -0
  32. package/dist/types/types/external.d.ts.map +1 -1
  33. package/dist/types/types/index.d.ts +1 -0
  34. package/dist/types/types/index.d.ts.map +1 -1
  35. package/dist/types/types/plugins.d.ts +81 -0
  36. package/dist/types/types/plugins.d.ts.map +1 -0
  37. package/dist/types/utils.d.ts +7 -4
  38. package/dist/types/utils.d.ts.map +1 -1
  39. package/docs/api/README.md +1 -1
  40. package/docs/api/functions.md +16 -8
  41. package/docs/api/interact-class.md +35 -0
  42. package/docs/api/types.md +95 -3
  43. package/docs/examples/list-patterns.md +4 -0
  44. package/docs/guides/README.md +4 -0
  45. package/docs/guides/configuration-structure.md +2 -0
  46. package/docs/guides/plugins.md +192 -0
  47. package/docs/guides/sequences.md +34 -1
  48. package/package.json +2 -2
  49. package/rules/click.md +2 -2
  50. package/rules/full-lean.md +79 -21
  51. package/rules/hover.md +2 -2
  52. package/rules/integration.md +20 -11
  53. package/rules/plugins.md +122 -0
  54. package/rules/pointermove.md +14 -22
  55. package/rules/validate.md +7 -4
  56. package/rules/viewenter.md +1 -1
  57. package/rules/viewprogress.md +4 -4
  58. package/dist/index-7fvAL10J.mjs +0 -3323
  59. package/dist/index-7fvAL10J.mjs.map +0 -1
  60. package/dist/index-C4A3nFix.js +0 -21
  61. package/dist/index-C4A3nFix.js.map +0 -1
@@ -24,6 +24,7 @@ Declarative configuration-driven interaction library. Binds animations to trigge
24
24
  - [Conditions](#conditions)
25
25
  - [CSS Generation & FOUC Prevention](#css-generation--fouc-prevention)
26
26
  - [Element Resolution](#element-resolution)
27
+ - [Plugins](#plugins)
27
28
  - [Static API](#static-api)
28
29
 
29
30
  ---
@@ -236,7 +237,7 @@ For most use cases, `key` alone is sufficient for both source and target resolut
236
237
  - `effectId`: string of the effect to wait for completion
237
238
  - Usage: Fire when the specified effect (by `effectId`) on the source element finishes, useful for chaining sequences.
238
239
  - pointerMove: `PointerMoveParams`
239
- - `hitArea?`: `'root' | 'self'` (default `'self'`)
240
+ - `hitArea?`: `'root' | 'self'` (default `'root'` — an omitted `hitArea` tracks the viewport)
240
241
  - `axis?`: `'x' | 'y'` - when using `keyframeEffect` with `pointerMove`, selects which pointer coordinate maps to linear 0-1 progress; defaults to `'y'`. Ignored for `namedEffect` and `customEffect`.
241
242
  - Usage:
242
243
  - `'self'`: Track pointer within the source element’s bounds.
@@ -282,8 +283,9 @@ For `TimeEffect` (keyframe/named/custom effects), set `triggerType` on the effec
282
283
 
283
284
  ```ts
284
285
  params: {
285
- threshold?: number; // 0–1, IntersectionObserver threshold
286
- inset?: string; // like view-timeline-inset, e.g. '-100px' or '-50px 0px'
286
+ threshold?: number; // 0–1, IntersectionObserver threshold (default 0.2)
287
+ inset?: string; // like view-timeline-inset, e.g. '-100px' or '-50px 0px'
288
+ useSafeViewEnter?: boolean; // default false; see below
287
289
  }
288
290
  // Playback behavior is set on each effect:
289
291
  effect.triggerType: 'once' | 'repeat' | 'alternate' | 'state'; // default: 'once'
@@ -291,6 +293,13 @@ effect.triggerType: 'once' | 'repeat' | 'alternate' | 'state'; // default: 'onc
291
293
 
292
294
  **CRITICAL:** When source and target are the **same element**, MUST use `triggerType: 'once'`. For `'repeat'` / `'alternate'` / `'state'`, ALWAYS use **separate** source and target elements — animating the observed element can cause it to leave/re-enter the viewport, causing rapid re-triggers.
293
295
 
296
+ **`useSafeViewEnter`** — guards against a `threshold` that can never be met. A `threshold` is a fraction of the **source's own box**, so when `sourceHeight × threshold` exceeds the viewport height the ratio is unreachable and the animation never fires. With this flag set, the first non-intersecting observer callback measures the source and, if the threshold is unreachable, swaps to a fallback observer (`threshold: 0`, `rootMargin: '0px 0px -10% 0px'`).
297
+
298
+ Two constraints that follow from the implementation:
299
+
300
+ - It only helps alongside an **explicit** `threshold`. The check reads the authored value, not the `0.2` default, so `useSafeViewEnter: true` on its own does nothing.
301
+ - The fallback observer uses a fixed config, so a configured `inset` is discarded once it kicks in.
302
+
294
303
  ### viewProgress
295
304
 
296
305
  Scroll-driven animations using native `ViewTimeline`, with polyfill where not supported. Progress is driven by scroll position. Control the range via `rangeStart`/`rangeEnd` on the effect (see [Scroll / Pointer-driven Effect](#scroll--pointer-driven-effect)).
@@ -316,7 +325,9 @@ params: {
316
325
  - For 2D effects, use `namedEffect` mouse presets or `customEffect`. `keyframeEffect` only supports a single axis.
317
326
  - For independent 2-axis control with keyframes, use two separate interactions (one `axis: 'x'`, one `axis: 'y'`) with `composite: 'add'` or `'accumulate'` on the second effect.
318
327
 
319
- **`centeredToTarget`** — set `true` to remap the `0–1` progress range so that `0.5` progress corresponds to the center of the target element. Use when source and target are different elements, or when `hitArea: 'root'` is used, so that the pointer resting over the target center produces 50% progress regardless of position in viewport.
328
+ **`centeredToTarget`** — set `true` to remap the `0–1` progress range so that `0.5` progress corresponds to the center of the target element. Use when source and target are different elements, or when `hitArea: 'root'` is used, so that the pointer resting over the target center produces 50% progress regardless of position in viewport. Applies to `namedEffect` and `customEffect` only: a `keyframeEffect` scrub scene resolves no target, so centering is silently ignored there.
329
+
330
+ **`transitionDuration` / `transitionEasing`** — progress smoothing. Forwarded **only** when the payload is a `customEffect`; they are dropped for `keyframeEffect` and `namedEffect` on `pointerMove`.
320
331
 
321
332
  **Progress object** (for `customEffect`):
322
333
 
@@ -405,10 +416,10 @@ Used with `viewProgress` and `pointerMove` triggers.
405
416
  reversed?: boolean;
406
417
  fill?: 'none' | 'forwards' | 'backwards' | 'both';
407
418
  composite?: 'replace' | 'add' | 'accumulate';
408
- centeredToTarget?: boolean;
409
- transitionDuration?: number; // ms, smoothing on progress jumps (primarily for pointerMove)
419
+ centeredToTarget?: boolean; // pointerMove; namedEffect / customEffect only — ignored for keyframeEffect
420
+ transitionDuration?: number; // ms, smoothing on progress jumps; pointerMove + customEffect only
410
421
  transitionDelay?: number; // ms (primarily for pointerMove)
411
- transitionEasing?: 'linear' | 'hardBackOut' | 'easeOut' | 'elastic' | 'bounce';
422
+ transitionEasing?: 'linear' | 'hardBackOut' | 'easeOut' | 'elastic' | 'bounce'; // pointerMove + customEffect only
412
423
  // + exactly one animation payload (see below)
413
424
  }
414
425
  ```
@@ -449,7 +460,7 @@ Used with `hover` / `click` triggers. Set `stateAction` on the effect to control
449
460
  - `transition?`: `{ duration?: number; delay?: number; easing?: string; styleProperties: { name: string; value: string }[] }`
450
461
  - Applies a single transition options block to all listed style properties.
451
462
  - `transitionProperties?`: `Array<{ name: string; value: string; duration?: number; delay?: number; easing?: string }>`
452
- - Allows per-property transition options. If both `transition` and `transitionProperties` are provided, the system SHOULD apply both with per-property entries taking precedence for overlapping properties.
463
+ - Allows per-property transition options. Set one or the other: if `transition.styleProperties` is present, `transitionProperties` is ignored **entirely** — it is not merged, and per-property entries do not take precedence for overlapping properties.
453
464
 
454
465
  ```ts
455
466
  // Shared timing for all properties:
@@ -468,7 +479,7 @@ Used with `hover` / `click` triggers. Set `stateAction` on the effect to control
468
479
  }
469
480
  ```
470
481
 
471
- CSS property names use **camelCase** (e.g. `'backgroundColor'`, `'borderRadius'`).
482
+ CSS property names may be written in **kebab-case** (`'background-color'`) or **camelCase** (`'backgroundColor'`) — both are accepted and normalized. Prefer kebab-case here: these properties are written into CSS. CSS custom properties (`--*`) are used verbatim and are case-sensitive.
472
483
 
473
484
  ### Animation Payloads
474
485
 
@@ -504,7 +515,7 @@ Exactly one MUST be provided per time-based or scroll/pointer-driven effect:
504
515
  ```
505
516
 
506
517
  - `[EFFECT_NAME]` — unique string identifier for this effect.
507
- - `[KEYFRAMES]` — array of keyframe objects using standard WAAPI format (e.g. `[{ opacity: '0' }, { opacity: '1' }]`). Property names in camelCase.
518
+ - `[KEYFRAMES]` — array of keyframe objects using standard WAAPI format (e.g. `[{ opacity: '0' }, { opacity: '1' }]`). Property names may be camelCase or kebab-case (both are accepted and normalized); prefer camelCase, which is what WAAPI uses. `offset`, `easing` and `composite` keep their WAAPI meaning, so the CSS `offset` property is written as `cssOffset`.
508
519
 
509
520
  3. **`customEffect`** — imperative update callback. Use only when CSS-based effects cannot express the desired behavior (e.g., animating SVG attributes, canvas, text content).
510
521
 
@@ -527,8 +538,10 @@ Coordinate multiple effects with staggered timing. Prefer sequences over manual
527
538
  effects: (Effect | EffectRef)[]; // REQUIRED
528
539
  delay?: number; // ms before sequence starts
529
540
  offset?: number; // ms between each child's animation start
530
- offsetEasing?: string; // easing curve for staggering offsets
531
- sequenceId?: string; // for caching/referencing
541
+ offsetEasing?: string; // easing curve for staggering offsets - keep it a string, a
542
+ // function excludes the sequence from generated CSS
543
+ sequenceId?: string; // for caching/referencing; also names the CSS stagger custom
544
+ // properties. Defaults to `seq-<interactionIdx>-<sequenceIdx>`
532
545
  conditions?: string[]; // ids referencing the top-level conditions map
533
546
  }
534
547
  ```
@@ -705,17 +718,62 @@ The target element is what the effect animates. Resolved in priority order:
705
718
 
706
719
  ---
707
720
 
721
+ ## Plugins
722
+
723
+ Interact can route config to external plugins registered with `Interact.use(name, plugin)`. Interact is only a bridge — it matches a `$<name>` config field to a registered plugin name and passes the value in; it never inspects plugin behavior. Neither Interact nor the plugin package depend on each other. A plugin package MAY ship its own adapter typed structurally against the contract (e.g. `@wix/splittext/plugin`) — use it instead of hand-rolling one; your app supplies only the type glue.
724
+
725
+ - Register before `create()`: `Interact.use('splitText', splitTextPlugin)`.
726
+ - Reference with a `$<name>` field on an **interaction** or **effect**: `$splitText: { container: '.title', type: 'chars' }`.
727
+ - Plugins run at connect time, **before** target resolution — so DOM they create (e.g. `.split-c` spans) is visible to `selector` queries that follow.
728
+ - A plugin may return a cleanup function; Interact runs it on disconnect/teardown.
729
+ - A `$<name>` field with no registered plugin is ignored.
730
+ - Plugin fields MUST be `$`-prefixed — a non-prefixed unknown key on an interaction/effect is rejected by `@wix/interact-validate`.
731
+ - **SSR styling:** for FOUC prevention (e.g. hiding un-split text before an entrance animation), pass a **separate** per-plugin callback in the `plugins` option of `generate()`'s options bag: `generate(config, { useFirstChild: true, plugins: { myPlugin: (value, context) => { declarations, selectorSuffix }[] } })`. `generate()` does not inspect the value; the callback returns CSS rule(s) data and scopes them under the base selector (`[data-interact-key="<key>"]`). It is NOT the `use()` callback. If the plugin package ships a generator (e.g. `splitTextStyle` from `@wix/splittext/plugin`), pass that instead of writing one.
732
+
733
+ **Example — split text, then stagger the generated char spans.** Use the adapter shipped from `@wix/splittext/plugin` (`splitTextPlugin` + its SSR counterpart `splitTextStyle`); do NOT hand-roll it:
734
+
735
+ ```js
736
+ import { Interact, generate } from '@wix/interact';
737
+ import { splitTextPlugin, splitTextStyle } from '@wix/splittext/plugin';
738
+
739
+ const config = {
740
+ effects: { 'char-fade-up': { namedEffect: { type: 'FadeIn' }, duration: 400 } },
741
+ interactions: [
742
+ {
743
+ key: 'hero',
744
+ trigger: 'viewEnter',
745
+ // `hideUntilReady` opts into the SSR hide rule emitted by splitTextStyle
746
+ $splitText: { container: '.title', type: 'chars', hideUntilReady: true },
747
+ sequences: [{ offset: 30, effects: [{ effectId: 'char-fade-up', selector: '.split-c' }] }],
748
+ },
749
+ ],
750
+ };
751
+
752
+ const css = generate(config, { useFirstChild: true, plugins: { splitText: splitTextStyle } });
753
+ // Embed css in HTML — see CSS Generation & FOUC Prevention
754
+
755
+ Interact.use('splitText', splitTextPlugin);
756
+
757
+ Interact.create(config);
758
+ ```
759
+
760
+ - `$splitText` takes `{ container, hideUntilReady?, ...SplitTextOptions }`; `container` is resolved within the element and every match is split.
761
+ - Type the field in your app: `declare module '@wix/interact' { interface InteractPluginConfigMap { splitText: SplitTextPluginConfig } }` (type from `@wix/splittext/plugin`).
762
+
763
+ Default split wrapper classes: `.split-c` (chars), `.split-w` (words), `.split-l` (lines), `.split-s` (sentences).
764
+
708
765
  ## Static API
709
766
 
710
- | Method / Property | Description |
711
- | :---------------------------------- | :------------------------------------------------------------------------------------------------------------ |
712
- | `generate(config, useFirstChild?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. |
713
- | `Interact.create(config)` | Initialize with a config. Returns the instance. Store the instance to manage its lifecycle. |
714
- | `Interact.registerEffects(presets)` | Register named effect presets. MUST be called before `generate()` and `create`. |
715
- | `Interact.destroy()` | Tear down all instances. Call on unmount or route change to prevent memory leaks. |
716
- | `Interact.forceReducedMotion` | `boolean` (default: `false`) — force reduced-motion behavior regardless of OS setting. |
717
- | `Interact.allowA11yTriggers` | `boolean` (default: `true`) — enable accessibility trigger variants (`interest`, `activate`). |
718
- | `Interact.setup(options)` | Configure global options for scroll, pointer, and viewEnter systems. Call before `create`. See options below. |
767
+ | Method / Property | Description |
768
+ | :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
769
+ | `generate(config, options?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. `options` = `{ useFirstChild?, plugins? }`, or a bare boolean for legacy `useFirstChild`. `plugins` = per-plugin SSR style generators (see [Plugins](#plugins)). |
770
+ | `Interact.create(config)` | Initialize with a config. Returns the instance. Store the instance to manage its lifecycle. |
771
+ | `Interact.registerEffects(presets)` | Register named effect presets. MUST be called before `generate()` and `create`. |
772
+ | `Interact.destroy()` | Tear down all instances. Call on unmount or route change to prevent memory leaks. |
773
+ | `Interact.forceReducedMotion` | `boolean` (default: `false`) — force reduced-motion behavior regardless of OS setting. |
774
+ | `Interact.allowA11yTriggers` | `boolean` (default: `true`) — enable accessibility trigger variants (`interest`, `activate`). |
775
+ | `Interact.setup(options)` | Configure global options for scroll, pointer, and viewEnter systems. Call before `create`. See options below. |
776
+ | `Interact.use(name, plugin)` | Register an external plugin by name (see [Plugins](#plugins)). Call before `create`. |
719
777
 
720
778
  **`Interact.setup(options)`** — optional configuration object:
721
779
 
package/rules/hover.md CHANGED
@@ -69,7 +69,7 @@ Use `keyframeEffect` or `namedEffect` when the hover should play an animation (C
69
69
  - `'repeat'` — restarts the animation from the beginning on each enter. On leave, jumps to the beginning and pauses.
70
70
  - `'once'` — plays once on the first enter and never again.
71
71
  - `'state'` — resumes on enter, pauses on leave. Useful for continuous loops (`iterations: Infinity`).
72
- - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names in camelCase.
72
+ - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names may be camelCase or kebab-case (both accepted); prefer camelCase, which is what WAAPI uses.
73
73
  - `[EFFECT_NAME]` — unique string identifier for a `keyframeEffect`.
74
74
  - `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built effect from `@wix/motion-presets`. Refer to motion-presets rules for available presets and their options.
75
75
  - `[DURATION_MS]` — animation duration in milliseconds.
@@ -131,7 +131,7 @@ Use `transition` when all properties share timing. Use `transitionProperties` wh
131
131
  - `'add'` — applies the style state on enter. Leave does NOT remove it.
132
132
  - `'remove'` — removes a previously applied style state on enter. Use with provided `effectId` to map to a matching interaction with `add` and effect with same `effectId`.
133
133
  - `'clear'` — clears all previously applied style states on enter. Use to reset multiple stacked `'add'` style changes at once (e.g. a "reset" hover area that undoes several accumulated states).
134
- - `[CSS_PROP]` — CSS property name as a string in camelCase format (e.g. `'backgroundColor'`, `'borderRadius'`, `'opacity'`).
134
+ - `[CSS_PROP]` — CSS property name as a string, in kebab-case (`'background-color'`) or camelCase (`'backgroundColor'`) — both accepted; prefer kebab-case, since these are written into CSS. Custom properties (`--*`) are used verbatim.
135
135
  - `[VALUE]` — target CSS value for the property.
136
136
  - `[DURATION_MS]` — transition duration in milliseconds.
137
137
  - `[DELAY_MS]` — optional transition delay in milliseconds.
@@ -269,11 +269,20 @@ Define reusable sequences in `InteractConfig.sequences` and reference by `sequen
269
269
  }
270
270
  ```
271
271
 
272
+ - **MUST** use a **string** `offsetEasing` (named key, `cubic-bezier(...)` or `linear(...)`) on any
273
+ sequence that needs generated CSS. `generate()` compiles the stagger into a `calc()` delay driven by
274
+ `--motion-<sequenceId>-index` custom properties, which a `(p: number) => number` function cannot
275
+ express — such a sequence is omitted from the generated CSS entirely and loses FOUC prevention.
276
+ `@wix/interact-validate` flags it as `FUNCTION_OFFSET_EASING` (warning, rule category `OFFSET_EASING`).
277
+ - **Rule**: `sequenceId` names those custom properties, so it must be identical on both sides.
278
+ Interact handles this for you — omitted ids default to `seq-<interactionIndex>-<sequenceIndex>`, derived
279
+ from the config position — but a hand-written id must be stable across CSS generation and runtime.
280
+
272
281
  ---
273
282
 
274
283
  ## CSS Generation & FOUC Prevention
275
284
 
276
- `generate(config, useFirstChild)` produces complete CSS for **all** interactions in the config — `@keyframes`, animation/transition custom properties, `view-timeline` declarations, state-selector rules, coordinated-list aggregation, and FOUC-prevention initial rules.
285
+ `generate(config, options?)` produces complete CSS for **all** interactions in the config — `@keyframes`, animation/transition custom properties, `view-timeline` declarations, state-selector rules, coordinated-list aggregation, and FOUC-prevention initial rules.
277
286
 
278
287
  **Static site policy:** For static or pre-rendered HTML (agent-generated pages,
279
288
  SSG, static export), prefer calling `generate()` for the complete config at
@@ -284,7 +293,7 @@ browser before its `Interact.create()` call. If splitting is impractical,
284
293
  generating the complete CSS at runtime is an acceptable fallback. Call
285
294
  `registerEffects()` before each `generate()` when using `namedEffect`.
286
295
 
287
- The `useFirstChild` argument tells Interact whether to render `:first-child` selectors for custom-element (`web`) integration: `true` for **web**, `false` for **react** and **vanilla**.
296
+ The `useFirstChild` option tells Interact whether to render `:first-child` selectors for custom-element (`web`) integration: `true` for **web**, `false` for **react** and **vanilla**. Pass it either as a bare boolean (`generate(config, true)`) or in the options bag (`generate(config, { useFirstChild: true })`) — the bag is also where `plugins` goes.
288
297
 
289
298
  ```javascript
290
299
  import { generate } from '@wix/interact/web';
@@ -344,12 +353,12 @@ See [viewenter.md](./viewenter.md) for full details.
344
353
 
345
354
  Each `Interact.create(config)` call returns an instance. Keep a reference if you need to add/remove elements dynamically (vanilla JS) or to destroy a specific instance. Call `Interact.destroy()` to tear down all instances at once (e.g. on page navigation).
346
355
 
347
- | Method / Property | Description |
348
- | :---------------------------------- | :------------------------------------------------------------------------------------------- |
349
- | `generate(config, useFirstChild?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. |
350
- | `Interact.create(config)` | Initialize with a config. Returns the instance. Multiple configs create separate instances. |
351
- | `Interact.registerEffects(presets)` | Register named effect presets before `generate()` and `create`. Required for `namedEffect`. |
352
- | `Interact.destroy()` | Tear down all instances. |
353
- | `Interact.forceReducedMotion` | `boolean` — force reduced-motion behavior regardless of OS setting. Default: `false`. |
354
- | `Interact.allowA11yTriggers` | `boolean` — enable accessibility triggers (`interest`, `activate`). Default: `false`. |
355
- | `Interact.setup(options)` | Configure global defaults for scroll/pointer/viewEnter trigger params. Call before `create`. |
356
+ | Method / Property | Description |
357
+ | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
358
+ | `generate(config, options?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. `options` = `{ useFirstChild?, plugins? }`, or a bare boolean for legacy `useFirstChild`. |
359
+ | `Interact.create(config)` | Initialize with a config. Returns the instance. Multiple configs create separate instances. |
360
+ | `Interact.registerEffects(presets)` | Register named effect presets before `generate()` and `create`. Required for `namedEffect`. |
361
+ | `Interact.destroy()` | Tear down all instances. |
362
+ | `Interact.forceReducedMotion` | `boolean` — force reduced-motion behavior regardless of OS setting. Default: `false`. |
363
+ | `Interact.allowA11yTriggers` | `boolean` — enable accessibility triggers (`interest`, `activate`). Default: `true`. |
364
+ | `Interact.setup(options)` | Configure global defaults for scroll/pointer/viewEnter trigger params. Call before `create`. |
@@ -0,0 +1,122 @@
1
+ # @wix/interact Plugin Rules
2
+
3
+ Rules for extending `@wix/interact` with external plugins via `Interact.use()` and `$`-prefixed config fields.
4
+
5
+ ## Model
6
+
7
+ Interact is a **generic bridge**. It knows a plugin only by the name it was registered under. When an interaction or effect carries a field named `$<name>`, Interact passes that field's value to the matching plugin and (optionally) stores a cleanup. Interact never inspects what the plugin does.
8
+
9
+ - `@wix/interact` has **no** plugin-specific code and does **not** depend on any plugin package.
10
+ - A plugin package (e.g. `@wix/splittext`) does **not** depend on `@wix/interact`.
11
+ - A plugin package MAY still ship a ready-made adapter (e.g. `@wix/splittext/plugin`), typed _structurally_ against the contract below so it stays assignable to `InteractPlugin` without importing Interact. Prefer the shipped adapter over hand-rolling one.
12
+ - Only the **typing** glue lives in your app — the declaration merge on `InteractPluginConfigMap` (see [Config placement](#config-placement)).
13
+
14
+ ## Registration
15
+
16
+ Register before `Interact.create()`:
17
+
18
+ ```js
19
+ Interact.use('<plugin-name>', (value, context) => {
20
+ // value: the value of the `$<plugin-name>` field
21
+ // context: { root, key, scope: 'interaction' | 'effect', config }
22
+ // return: optional cleanup () => void, run on disconnect/teardown
23
+ });
24
+ ```
25
+
26
+ - `Interact.getPlugin(name) / Interact.getPluginsNames()` inspect the registry.
27
+
28
+ ## Config placement
29
+
30
+ Add a `$<plugin-name>` field on an **interaction** or an **effect**:
31
+
32
+ ```js
33
+ {
34
+ key: 'hero',
35
+ trigger: 'viewEnter',
36
+ $splitText: { /* any value */ },
37
+ effects: [ /* ... */ ],
38
+ }
39
+ ```
40
+
41
+ ## Rules
42
+
43
+ - **MUST** register the plugin (`Interact.use`) before `Interact.create()`. A `$<name>` field with no registered plugin is ignored.
44
+ - **MUST** prefix plugin fields with `$` (e.g. `$splitText`). A non-prefixed unknown key on an interaction/effect is rejected by `@wix/interact-validate` (via `catchall` + key check). Only `$`-prefixed fields are treated as opaque, un-inspected plugin config.
45
+ - Use a bare, unquoted `$<name>` key — no quotes needed since `$` is a valid identifier start (e.g. `$splitText:`, not `'plugin:splitText':`).
46
+ - Plugins run at **connect time, before target resolution** — DOM a plugin creates is visible to the `selector` / `listContainer` queries that follow.
47
+ - A returned cleanup runs on disconnect, on `Interact.destroy()`, and on media-query reconnect. Use it to fully undo the plugin's work.
48
+ - Each distinct plugin value is applied **once per connect**, even across multiple triggers on the same element.
49
+ - Interaction-level fields use the interaction's element as `root`; effect-level fields use the effect's target element as `root`.
50
+
51
+ ## SSR styling (FOUC prevention)
52
+
53
+ Runtime plugins mutate the DOM only after JS loads. To style the element _before_ that (e.g. hide un-split text so an entrance animation doesn't flash), pass a **separate** per-plugin callback in the `plugins` option of `generate()`'s options bag:
54
+
55
+ ```js
56
+ const css = generate(config, {
57
+ useFirstChild: true,
58
+ plugins: {
59
+ myPlugin: (value, _context) => {
60
+ // value: the opaque `$myPlugin` value;
61
+ // context: { key, scope: 'interaction' | 'effect', config }
62
+ // return: { declarations: { name: string; value: number | string }[]; selectorSuffix?: string }[]
63
+ return [
64
+ {
65
+ declarations: [{ name: 'visibility', value: 'hidden' }],
66
+ selectorSuffix: ` ${value.container ?? ''}:not([data-myplugin-ready])`,
67
+ },
68
+ ];
69
+ },
70
+ },
71
+ });
72
+ ```
73
+
74
+ - If the plugin package ships its own generator, pass that instead of writing one — e.g. `splitTextStyle` from `@wix/splittext/plugin` (see the example below).
75
+ - This is **NOT** the callback registered via `Interact.use()` — it's a build-time styling generator.
76
+ - `generate()` does **not** inspect the `$<name>` value (same as `create()`); it just routes it to the generator, which returns partial CSS rule(s) data.
77
+ - `declarations` is an array of names and values of CSS properties to set; `selectorSuffix` is used to refine the target of the CSS rule - the resulting selector for the rule is `[data-interact-key=${key}]${selectorSuffix}`
78
+ - Context: `{ key, scope: 'interaction' | 'effect', config }`.
79
+ - Typical pattern: the runtime plugin sets a marker attribute after applying (e.g. `data-splittext-ready`), and the SSR rule hides until that marker is present.
80
+
81
+ ## Example: `@wix/splittext`
82
+
83
+ Split text into `<span>`s, then target the generated spans with a normal `selector`. Default classes: `.split-c` (chars), `.split-w` (words), `.split-l` (lines), `.split-s` (sentences).
84
+
85
+ **Do NOT hand-roll this adapter.** `@wix/splittext/plugin` ships both callbacks — `splitTextPlugin` (runtime) and `splitTextStyle` (SSR) — already paired on the `data-splittext-ready` marker:
86
+
87
+ ```js
88
+ import { Interact, generate } from '@wix/interact';
89
+ import { splitTextPlugin, splitTextStyle } from '@wix/splittext/plugin';
90
+
91
+ const config = {
92
+ effects: { 'char-fade-up': { namedEffect: { type: 'FadeIn' }, duration: 400 } },
93
+ interactions: [
94
+ {
95
+ key: 'hero',
96
+ trigger: 'viewEnter',
97
+ // `hideUntilReady` opts into the SSR hide rule emitted by splitTextStyle
98
+ $splitText: { container: '.title', type: 'chars', hideUntilReady: true },
99
+ sequences: [{ offset: 30, effects: [{ effectId: 'char-fade-up', selector: '.split-c' }] }],
100
+ },
101
+ ],
102
+ };
103
+
104
+ Interact.use('splitText', splitTextPlugin);
105
+
106
+ const css = generate(config, { useFirstChild: true, plugins: { splitText: splitTextStyle } });
107
+ // Embed css in HTML — see CSS Generation & FOUC Prevention
108
+
109
+ Interact.create(config);
110
+ ```
111
+
112
+ To type the `$splitText` field, declaration-merge in your app (the only place importing both packages):
113
+
114
+ ```ts
115
+ import type { SplitTextPluginConfig } from '@wix/splittext/plugin';
116
+
117
+ declare module '@wix/interact' {
118
+ interface InteractPluginConfigMap {
119
+ splitText: SplitTextPluginConfig;
120
+ }
121
+ }
122
+ ```
@@ -36,9 +36,9 @@ type PointerMoveParams = {
36
36
 
37
37
  ### Properties
38
38
 
39
- - `hitArea` — determines where mouse movement is tracked:
39
+ - `hitArea` — determines where mouse movement is tracked. **Omitting it behaves as `'root'`**: only an explicit `'self'` scopes tracking to the source element.
40
40
  - `'self'` — tracks pointer within the source element's bounds only. Use for local pointer-tracking effects on a specific element.
41
- - `'root'` — tracks pointer anywhere in the viewport. Use for global cursor followers, ambient effects.
41
+ - `'root'` (default) — tracks pointer anywhere in the viewport. Use for global cursor followers, ambient effects.
42
42
  - `axis` — restricts pointer tracking to a single axis. Used with `keyframeEffect` to map one axis to 0–1 progress; ignored by `namedEffect` and `customEffect` which receive the full 2D progress:
43
43
  - `'x'` — maps horizontal pointer position to 0–1 progress for keyframe interpolation.
44
44
  - `'y'` — maps vertical pointer position to 0–1 progress for keyframe interpolation. **Default** when `keyframeEffect` is used.
@@ -69,7 +69,9 @@ type Progress = {
69
69
  Controls which element's bounds define the 0–1 progress range.
70
70
 
71
71
  - **`false` (default)**: Progress is calculated against the **source element's** (or viewport's) bounds. The `50%` progress of the timeline is at the center of the source element.
72
- - **`true`**: `50%` progress of the timeline is calculated against the **target element's center**. The edges of the timeline are still calculated against the edges of the source element/viewport depending on `hitAea`.
72
+ - **`true`**: `50%` progress of the timeline is calculated against the **target element's center**. The edges of the timeline are still calculated against the edges of the source element/viewport depending on `hitArea`.
73
+
74
+ **Applies to `namedEffect` and `customEffect` only.** Centering needs a resolved target, and a `keyframeEffect` scrub scene resolves none — set it there and it is silently ignored.
73
75
 
74
76
  ---
75
77
 
@@ -118,9 +120,7 @@ Use pre-built mouse presets from `@wix/motion-presets` that handle 2D mouse trac
118
120
  type: '[NAMED_EFFECT_TYPE]',
119
121
  [EFFECT_PROPERTIES]
120
122
  },
121
- centeredToTarget: [CENTERED_TO_TARGET],
122
- transitionDuration: [TRANSITION_DURATION_MS],
123
- transitionEasing: '[TRANSITION_EASING]'
123
+ centeredToTarget: [CENTERED_TO_TARGET]
124
124
  },
125
125
  // additional effects targeting other elements can be added here
126
126
  ]
@@ -135,8 +135,8 @@ Use pre-built mouse presets from `@wix/motion-presets` that handle 2D mouse trac
135
135
  - `[NAMED_EFFECT_TYPE]` — a registered effect name, or a preset from `@wix/motion-presets` `mouse` library.
136
136
  - `[EFFECT_PROPERTIES]` — preset-specific options. Refer to motion-presets rules for each preset's available options and their value types. Do NOT guess preset option names or types; omit unknown options and rely on defaults.
137
137
  - `[CENTERED_TO_TARGET]` — `true` or `false`. See **Centering with `centeredToTarget`** above.
138
- - `[TRANSITION_DURATION_MS]` — optional number. Milliseconds for smoothing (interpolating) between progress updates. The animation does not jump to the new progress value instantly; instead it transitions over this duration. Use to add inertia/lag to the effect, making it feel more physical (e.g. `200`–`600`).
139
- - `[TRANSITION_EASING]` — optional string. CSS easing or named easing from `@wix/motion`. Adds a natural deceleration feel when used with `transitionDuration`.
138
+
139
+ > `transitionDuration` / `transitionEasing` are **not** available here. They are forwarded only for a `customEffect` payload (see Rule 4).
140
140
 
141
141
  ---
142
142
 
@@ -160,9 +160,6 @@ Use `keyframeEffect` when the pointer position along a single axis should drive
160
160
  keyframes: [KEYFRAMES]
161
161
  },
162
162
  fill: 'both',
163
- centeredToTarget: [CENTERED_TO_TARGET],
164
- transitionDuration: [TRANSITION_DURATION_MS],
165
- transitionEasing: '[TRANSITION_EASING]',
166
163
  effectId: '[UNIQUE_EFFECT_ID]'
167
164
  },
168
165
  // additional effects targeting other elements can be added here
@@ -177,11 +174,10 @@ Use `keyframeEffect` when the pointer position along a single axis should drive
177
174
  - `[AXIS]` — `'x'` (horizontal) or `'y'` (vertical). Defaults to `'y'` when omitted.
178
175
  - `[EFFECT_NAME]` — unique string name for the keyframe effect.
179
176
  - `[KEYFRAMES]` — array of CSS keyframe objects (e.g. `[{ transform: 'rotate(-10deg)' }, { transform: 'rotate(0)' }, { transform: 'rotate(10deg)' }]`). Distributed evenly across 0–1 progress: first keyframe = progress 0 (left/top edge), last = progress 1 (right/bottom edge). Any number of keyframes is allowed.
180
- - `[CENTERED_TO_TARGET]` — optional. `true` or `false`. See **Centering with `centeredToTarget`** above. Defaults to `false`.
181
- - `[TRANSITION_DURATION_MS]` — optional. Milliseconds for smoothing between progress updates. See Rule 1 for details.
182
- - `[TRANSITION_EASING]` — optional. CSS easing string or named easing from `@wix/motion`. See Rule 1 for supported values.
183
177
  - `[UNIQUE_EFFECT_ID]` — optional string identifier.
184
178
 
179
+ > A `keyframeEffect` scrub scene resolves no target, so `centeredToTarget` is silently ignored here, and `transitionDuration` / `transitionEasing` are not forwarded either. All three apply only to the payloads noted in Rules 1 and 4. For smoothed, centered pointer motion use a mouse `namedEffect` or a `customEffect`.
180
+
185
181
  ---
186
182
 
187
183
  ## Rule 3: Two keyframeEffects with Two Axes and `composite`
@@ -211,9 +207,7 @@ Use two separate interactions on the same source/target pair — one for `axis:
211
207
  keyframes: [X_KEYFRAMES]
212
208
  },
213
209
  fill: '[FILL_MODE]', // usually 'both'
214
- composite: '[COMPOSITE_OPERATION]',
215
- transitionDuration: [TRANSITION_DURATION_MS],
216
- transitionEasing: '[TRANSITION_EASING]'
210
+ composite: '[COMPOSITE_OPERATION]'
217
211
  },
218
212
  '[Y_EFFECT_ID]': {
219
213
  keyframeEffect: {
@@ -221,9 +215,7 @@ Use two separate interactions on the same source/target pair — one for `axis:
221
215
  keyframes: [Y_KEYFRAMES]
222
216
  },
223
217
  fill: '[FILL_MODE]', // usually 'both'
224
- composite: '[COMPOSITE_OPERATION]',
225
- transitionDuration: [TRANSITION_DURATION_MS],
226
- transitionEasing: '[TRANSITION_EASING]'
218
+ composite: '[COMPOSITE_OPERATION]'
227
219
  }
228
220
  }
229
221
  }
@@ -238,8 +230,8 @@ Use two separate interactions on the same source/target pair — one for `axis:
238
230
  - `[X_KEYFRAMES]` / `[Y_KEYFRAMES]` — arrays of WAAPI keyframe objects for the X-axis and Y-axis effects respectively. Each effect can vary in propertise and keyframes.
239
231
  - `[COMPOSITE_OPERATION]` — `'add'` or `'accumulate'`. Required when both effects animate `transform` and/or both animate `filter`, so their values combine rather than override. `'add'`: composited transform functions are appended. `'accumulate'`: matching function arguments are summed.
240
232
  - `[FILL_MODE]` — typically `'both'` to ensure the effect keeps applying after exiting the effect's active range.
241
- - `[TRANSITION_DURATION_MS]` — optional. Milliseconds for smoothing between progress updates. See Rule 1 for details.
242
- - `[TRANSITION_EASING]` — optional. CSS easing function for the smoothing transition. See Rule 1 for supported values.
233
+
234
+ > As in Rule 2, `transitionDuration` / `transitionEasing` / `centeredToTarget` do not apply to a `keyframeEffect` payload.
243
235
 
244
236
  ---
245
237
 
package/rules/validate.md CHANGED
@@ -56,7 +56,7 @@ if (!result.valid) {
56
56
  - `valid` is `true` when no remaining issue has severity `'error'`. **Warnings alone do not make `valid: false`.**
57
57
  - `errors` holds **all** surfaced issues — both `'error'` and `'warning'` severities. Filter on `severity` to separate them.
58
58
  - Issues are sorted lexicographically by `path`.
59
- - Validation runs in two layers: a **structural** zod parse first (produces `SCHEMA_*` and numeric/threshold codes); if that succeeds, **referential + semantic** checks run (dangling references, unused definitions, duplicate keyframe names, media-query syntax, and the rule-derived semantic warnings — same-element re-trigger, hit-area shift, scroll-preset `range`, `animationEnd` graph cycles, element-selection coherence, `fill`/`inset`/keyframe-camelCase nudges). If the structural parse fails, the semantic layer is skipped.
59
+ - Validation runs in two layers: a **structural** zod parse first (produces `SCHEMA_*` and numeric/threshold codes); if that succeeds, **referential + semantic** checks run (dangling references, unused definitions, duplicate keyframe names, media-query syntax, and the rule-derived semantic warnings — same-element re-trigger, hit-area shift, scroll-preset `range`, `animationEnd` graph cycles, element-selection coherence, `fill`/`inset` nudges, CSS property names that are neither camelCase nor kebab-case, sequence easings that cannot be compiled to CSS). If the structural parse fails, the semantic layer is skipped.
60
60
 
61
61
  ### assertValidInteractConfig
62
62
 
@@ -140,8 +140,9 @@ Severity is one of `'error' | 'warning'`. There are exactly two levers:
140
140
  | `STATE_EFFECT` | `EMPTY_STYLE_PROPERTIES`, `STATE_REMOVE_WITHOUT_EFFECT_ID` | warning |
141
141
  | `RECOMMENDED_FILL` | `RECOMMENDED_FILL_BOTH` | info |
142
142
  | `POINTER_AXIS` | `POINTER_AXIS_IGNORED` | warning |
143
- | `KEYFRAME_STYLE` | `KEYFRAME_PROP_NOT_CAMEL_CASE` | warning |
143
+ | `CSS_PROPERTY_NAME` | `INVALID_CSS_PROPERTY_NAME` | warning |
144
144
  | `VIEW_INSET` | `INVALID_INSET` | warning |
145
+ | `OFFSET_EASING` | `FUNCTION_OFFSET_EASING` | warning |
145
146
 
146
147
  For each category, set `'off'` to drop those issues entirely, `'warning'` / `'error'` to set their severity:
147
148
 
@@ -235,8 +236,9 @@ Statically-detectable authoring pitfalls lifted from the trigger rule files. Eac
235
236
  | `RECOMMENDED_FILL_BOTH` | A scrubbed (`viewProgress`/`pointerMove`) or toggling (`alternate`/`repeat`/`state`) effect omits `fill: 'both'`. | `RECOMMENDED_FILL` |
236
237
  | `RECOMMENDED_FILL_BACKWARDS` | A `viewEnter` + `once` named/keyframe effect targeting another element or using a same-element delay omits `fill: 'backwards'` or `'both'`. | `RECOMMENDED_FILL` |
237
238
  | `POINTER_AXIS_IGNORED` | `pointerMove` `params.axis` set on a `namedEffect`/`customEffect` (axis only applies to `keyframeEffect`). | `POINTER_AXIS` |
238
- | `KEYFRAME_PROP_NOT_CAMEL_CASE` | A `keyframeEffect` property name is kebab-case (not WAAPI camelCase). | `KEYFRAME_STYLE` |
239
+ | `INVALID_CSS_PROPERTY_NAME` | A keyframe or state-effect property name is neither camelCase nor kebab-case (both casings are accepted; this one cannot be normalized). | `CSS_PROPERTY_NAME` |
239
240
  | `INVALID_INSET` | `viewEnter` `params.inset` is not 1–4 whitespace-separated CSS lengths/percentages. | `VIEW_INSET` |
241
+ | `FUNCTION_OFFSET_EASING` | A sequence's `offsetEasing` is a function, so `generate()` omits that sequence from the generated CSS. | `OFFSET_EASING` |
240
242
 
241
243
  ---
242
244
 
@@ -277,7 +279,8 @@ const ExperienceSchema = z.object({
277
279
 
278
280
  - `InteractConfigSchema` is `.strict()` — unrecognized top-level keys produce `SCHEMA_UNRECOGNIZED_KEYS`.
279
281
  - `InteractConfigSchema` carries a `.transform()`, so a successful `.parse()` returns the config augmented with an internal `warnings` array; `validateInteractConfig` consumes that for you.
280
- - `customEffect` and function-valued `offsetEasing` are accepted as opaque functions (`z.custom<Function>`) — they are not deep-validated, so JS-authored configs with function fields validate correctly.
282
+ - `customEffect` and function-valued `offsetEasing` are accepted as opaque functions (`z.custom<Function>`) — they are not deep-validated, so JS-authored configs with function fields validate correctly. A function `offsetEasing` is still structurally valid, but raises the `FUNCTION_OFFSET_EASING` warning because `generate()` cannot compile it to CSS.
283
+ - Interactions and effects accept `$`-prefixed plugin fields (e.g. `$splitText`) — config routed to plugins registered via `Interact.use()`. Interaction/effect schemas use `.catchall(z.unknown())` + a key check instead of `.strict()`: `$`-prefixed fields are accepted with opaque values (validate has no knowledge of any plugin's shape), while any non-prefixed unknown key is still reported as `SCHEMA_UNRECOGNIZED_KEYS` (typo detection preserved). The top-level `InteractConfigSchema` stays `.strict()`.
281
284
 
282
285
  ---
283
286
 
@@ -152,7 +152,7 @@ Use `keyframeEffect` or `namedEffect` when the viewEnter should play an animatio
152
152
  - `'state'` — resumes on enter, pauses on leave. Useful for continuous loops (`iterations: Infinity`). Use separate source and target.
153
153
  - `[VISIBILITY_THRESHOLD]` — optional. Number between 0–1 indicating how much of the source element must be visible to trigger (e.g. `0.3` = 30%).
154
154
  - `[VIEWPORT_INSETS]` — optional. String adjusting the viewport detection area (e.g. `'-100px'` extends it, `'50px'` shrinks it).
155
- - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names in camelCase.
155
+ - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names may be camelCase or kebab-case (both accepted); prefer camelCase, which is what WAAPI uses.
156
156
  - `[EFFECT_NAME]` — unique string identifier for a `keyframeEffect`.
157
157
  - `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built effect from `@wix/motion-presets`. Refer to motion-presets rules for available presets and their options.
158
158
  - `[FILL_MODE]` — `'both'` for `triggerType: 'alternate'`, `'repeat'`, or `'state'`. For `triggerType: 'once'`: use `'backwards'` for entrance, so the first keyframe applies during any `delay` (use `'both'` when the final keyframe must persist after the animation).
@@ -55,14 +55,14 @@ For static sites, pre-render CSS via `generate()` at build time — see
55
55
  - `[TARGET_KEY]` — identifier matching the element's key (`data-interact-key` for web, `interactKey` for React) on the element to animate (can be same as source or different).
56
56
  - `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built effect from `@wix/motion-presets`. **CRITICAL:** Scroll presets (`*Scroll`) MUST include `range: 'in' | 'out' | 'continuous'` in their options. `'in'` ends at the idle state, `'out'` starts from the idle state, `'continuous'` passes through it.
57
57
  - `[EFFECT_NAME]` — unique name for custom keyframe effect.
58
- - `[EFFECT_KEYFRAMES]` — array of keyframe objects defining CSS property values (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names in camelCase.
58
+ - `[EFFECT_KEYFRAMES]` — array of keyframe objects defining CSS property values (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names may be camelCase or kebab-case (both accepted); prefer camelCase, which is what WAAPI uses.
59
59
  - `[RANGE_NAME]` — scroll range name:
60
60
  - `'cover'` — full visibility span from first pixel entering to last pixel leaving.
61
61
  - `'entry'` — the phase while the element is entering the viewport.
62
62
  - `'exit'` — the phase while the element is exiting the viewport.
63
- - `'contain'` — while the element is fully contained in the viewport. Typically used with a `position: sticky` container.
64
- - `'entry-crossing'` — from the element's leading edge entering to its leading edge reaching the opposite side.
65
- - `'exit-crossing'` — from the element's trailing edge reaching the start to its trailing edge leaving.
63
+ - `'contain'` — while the element is fully contained by the viewport, or — for an element taller than the viewport — while it fully covers it. This is the phase a `position: sticky` child stays pinned, which is why it pairs with a sticky container.
64
+ - `'entry-crossing'` — from the element's leading edge entering to its trailing edge entering.
65
+ - `'exit-crossing'` — from the element's leading edge exiting to its trailing edge exiting.
66
66
  - `[START_PERCENTAGE]` — 0–100, starting point within the named range.
67
67
  - `[END_PERCENTAGE]` — 0–100, end point within the named range.
68
68
  - `[EASING_FUNCTION]` - CSS easing string or named easing from `@wix/motion`. Typically `'linear'` for scrolling effects.