@wix/interact 2.5.25 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) 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-1AmVTHDV.mjs → index-76zNBcNy.mjs} +1232 -1156
  9. package/dist/index-76zNBcNy.mjs.map +1 -0
  10. package/dist/index-BMJFenGC.js +29 -0
  11. package/dist/index-BMJFenGC.js.map +1 -0
  12. package/dist/tsconfig.build.tsbuildinfo +1 -1
  13. package/dist/types/core/Interact.d.ts +14 -2
  14. package/dist/types/core/Interact.d.ts.map +1 -1
  15. package/dist/types/core/InteractionController.d.ts +1 -0
  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/resolvers.d.ts.map +1 -1
  19. package/dist/types/handlers/pointerMove.d.ts.map +1 -1
  20. package/dist/types/types/controller.d.ts +5 -0
  21. package/dist/types/types/controller.d.ts.map +1 -1
  22. package/dist/types/types/external.d.ts +1 -1
  23. package/dist/types/types/external.d.ts.map +1 -1
  24. package/dist/types/types/plugins.d.ts +10 -0
  25. package/dist/types/types/plugins.d.ts.map +1 -1
  26. package/docs/api/interact-class.md +28 -2
  27. package/docs/api/types.md +12 -0
  28. package/docs/guides/effects-and-animations.md +1 -1
  29. package/docs/guides/plugins.md +36 -1
  30. package/package.json +2 -2
  31. package/rules/full-lean.md +8 -6
  32. package/rules/plugins.md +19 -1
  33. package/rules/pointermove.md +3 -3
  34. package/dist/index-1AmVTHDV.mjs.map +0 -1
  35. package/dist/index-D-S2Tzk9.js +0 -29
  36. package/dist/index-D-S2Tzk9.js.map +0 -1
package/rules/plugins.md CHANGED
@@ -25,6 +25,23 @@ Interact.use('<plugin-name>', (value, context) => {
25
25
 
26
26
  - `Interact.getPlugin(name) / Interact.getPluginsNames()` inspect the registry.
27
27
 
28
+ ### Deferring (hydration)
29
+
30
+ When a framework hydrates or owns the DOM (e.g. React), defer DOM-changing plugins until the framework is done, then release:
31
+
32
+ ```js
33
+ Interact.use('splitText', splitTextPlugin, { defer: 'hydrated' });
34
+ Interact.create(config);
35
+
36
+ // React client root — effects run after the hydration commit
37
+ useEffect(() => Interact.ready('hydrated'), []);
38
+ ```
39
+
40
+ - While deferred, the plugin does not run, and neither does what carries its `$<name>` field: the whole interaction (interaction-level field), only that effect (effect-level field), or the whole sequence (field on any sequence effect). Everything else applies immediately.
41
+ - `Interact.ready(name, key)` releases a name for one element only; `Interact.ready(name)` releases it for all.
42
+ - `defer` may list several names (e.g. `['hydrated', 'fonts']`); all must be released. Release `'fonts'` with `document.fonts.ready.then(() => Interact.ready('fonts'))`.
43
+ - Released names persist until `Interact.destroy()`.
44
+
28
45
  ## Config placement
29
46
 
30
47
  Add a `$<plugin-name>` field on an **interaction** or an **effect**:
@@ -45,7 +62,8 @@ Add a `$<plugin-name>` field on an **interaction** or an **effect**:
45
62
  - Use a bare, unquoted `$<name>` key — no quotes needed since `$` is a valid identifier start (e.g. `$splitText:`, not `'plugin:splitText':`).
46
63
  - Plugins run at **connect time, before target resolution** — DOM a plugin creates is visible to the `selector` / `listContainer` queries that follow.
47
64
  - 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.
65
+ - Each distinct plugin value is applied **once per connect**, even across multiple triggers on the same element. Use object values — the dedup is by identity.
66
+ - **SHOULD** pass `{ defer: 'hydrated' }` to `Interact.use()` for DOM-changing plugins (e.g. `splitTextPlugin`) in apps that hydrate server-rendered markup, and call `Interact.ready('hydrated')` after hydration.
49
67
  - Interaction-level fields use the interaction's element as `root`; effect-level fields use the effect's target element as `root`.
50
68
 
51
69
  ## SSR styling (FOUC prevention)
@@ -71,7 +71,7 @@ Controls which element's bounds define the 0–1 progress range.
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
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
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.
74
+ **Applies to `namedEffect`, `customEffect`, and `keyframeEffect`.**
75
75
 
76
76
  ---
77
77
 
@@ -176,7 +176,7 @@ Use `keyframeEffect` when the pointer position along a single axis should drive
176
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.
177
177
  - `[UNIQUE_EFFECT_ID]` — optional string identifier.
178
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`.
179
+ > `centeredToTarget`, `transitionDuration`, and `transitionEasing` are supported here: centering remaps progress so `0.5` sits at the target's center, and the transition options smooth the pointer progress toward each new position.
180
180
 
181
181
  ---
182
182
 
@@ -231,7 +231,7 @@ Use two separate interactions on the same source/target pair — one for `axis:
231
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.
232
232
  - `[FILL_MODE]` — typically `'both'` to ensure the effect keeps applying after exiting the effect's active range.
233
233
 
234
- > As in Rule 2, `transitionDuration` / `transitionEasing` / `centeredToTarget` do not apply to a `keyframeEffect` payload.
234
+ > As in Rule 2, `centeredToTarget`, `transitionDuration`, and `transitionEasing` apply to a `keyframeEffect` payload.
235
235
 
236
236
  ---
237
237