@wix/interact 2.5.5 → 2.5.6
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/README.md +1 -1
- 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-7fvAL10J.mjs → index-CEt49C5d.mjs} +1241 -1107
- package/dist/index-CEt49C5d.mjs.map +1 -0
- package/dist/index-CxaQDD-U.js +21 -0
- package/dist/index-CxaQDD-U.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/core/Interact.d.ts +10 -1
- package/dist/types/core/Interact.d.ts.map +1 -1
- package/dist/types/core/InteractionController.d.ts +3 -1
- package/dist/types/core/InteractionController.d.ts.map +1 -1
- package/dist/types/core/add.d.ts.map +1 -1
- package/dist/types/core/css.d.ts +12 -4
- package/dist/types/core/css.d.ts.map +1 -1
- package/dist/types/core/cssUtils.d.ts.map +1 -1
- package/dist/types/types/config.d.ts +2 -1
- package/dist/types/types/config.d.ts.map +1 -1
- package/dist/types/types/controller.d.ts +5 -0
- package/dist/types/types/controller.d.ts.map +1 -1
- package/dist/types/types/css.d.ts +15 -1
- package/dist/types/types/css.d.ts.map +1 -1
- package/dist/types/types/effects.d.ts +2 -1
- package/dist/types/types/effects.d.ts.map +1 -1
- package/dist/types/types/external.d.ts +2 -0
- package/dist/types/types/external.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/plugins.d.ts +81 -0
- package/dist/types/types/plugins.d.ts.map +1 -0
- package/dist/types/utils.d.ts +7 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/README.md +1 -1
- package/docs/api/functions.md +16 -8
- package/docs/api/interact-class.md +35 -0
- package/docs/api/types.md +93 -1
- package/docs/guides/README.md +4 -0
- package/docs/guides/configuration-structure.md +2 -0
- package/docs/guides/plugins.md +192 -0
- package/package.json +2 -2
- package/rules/click.md +2 -2
- package/rules/full-lean.md +57 -11
- package/rules/hover.md +2 -2
- package/rules/integration.md +11 -11
- package/rules/plugins.md +122 -0
- package/rules/validate.md +4 -3
- package/rules/viewenter.md +1 -1
- package/rules/viewprogress.md +1 -1
- package/dist/index-7fvAL10J.mjs.map +0 -1
- package/dist/index-C4A3nFix.js +0 -21
- package/dist/index-C4A3nFix.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,yBAAyB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhG,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAE9D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,WAEzC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,UAExD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,CAAC,CAAC,GAAG,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAC9C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAClC,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKtF;AAED,wBAAgB,UAAU,WAQzB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,IAAI,CAAC,WAAW,EAAE,YAAY,GAAG,sBAAsB,CAAC,GACzE,aAAa,EAAE,CAQjB;AAED,wBAAgB,iCAAiC,CAAC,gBAAgB,EAAE,WAAW,YAwC9E;AAID,wBAAgB,mBAAmB,CAAC,EAClC,GAAG,EACH,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,aAAgC,EAChC,iBAAiB,GAClB,EAAE,yBAAyB,GAAG,MAAM,EAAE,CAyCtC;AAED,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,EACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EACrC,IAAI,EAAE,OAAO,GAAG,WAAW,UAY5B;AAED,wBAAgB,aAAa,CAC3B,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,EACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,uBAMtC;AAED,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,EACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACpC,MAAM,GAAG,SAAS,CASpB"}
|
package/docs/api/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Complete reference documentation for all public APIs in `@wix/interact`.
|
|
|
18
18
|
- [Error handling](functions.md#error-handling) and [performance considerations](functions.md#performance-considerations)
|
|
19
19
|
- [**remove(path)**](functions.md#remove) - Remove interactions from an element
|
|
20
20
|
- [Cleanup behavior](functions.md#behavior-details) and [advanced usage](functions.md#advanced-usage)
|
|
21
|
-
- [**generate(config,
|
|
21
|
+
- [**generate(config, options?)**](functions.md#generate) - Generate complete CSS for all animations, transitions, scroll-driven effects, and FOUC prevention
|
|
22
22
|
- [What it generates](functions.md#what-it-generates), [benefits](functions.md#benefits), and [use cases](functions.md#use-cases)
|
|
23
23
|
- [FOUC prevention](functions.md#fouc-prevention-viewenter), [scroll-driven CSS](functions.md#scroll-driven-css-viewprogress), and [SSR](functions.md#server-side-rendering-ssr)
|
|
24
24
|
- [**addListItems(root, key, listContainer, elements)**](functions.md#addlistitems) - Add interactions to new list items
|
package/docs/api/functions.md
CHANGED
|
@@ -12,11 +12,11 @@ import { add, remove, generate } from '@wix/interact';
|
|
|
12
12
|
|
|
13
13
|
## Functions Overview
|
|
14
14
|
|
|
15
|
-
| Function | Purpose | Parameters
|
|
16
|
-
| ------------ | -------------------------------------------------------------------------------- |
|
|
17
|
-
| `add()` | Add interactions to an element | `element`, `key?`
|
|
18
|
-
| `remove()` | Remove interactions from an element | `key`
|
|
19
|
-
| `generate()` | Generate complete CSS for all animations, transitions, and scroll-driven effects | `config`, `useFirstChild?` | `string` |
|
|
15
|
+
| Function | Purpose | Parameters | Returns |
|
|
16
|
+
| ------------ | -------------------------------------------------------------------------------- | -------------------------------------- | -------- |
|
|
17
|
+
| `add()` | Add interactions to an element | `element`, `key?` | `void` |
|
|
18
|
+
| `remove()` | Remove interactions from an element | `key` | `void` |
|
|
19
|
+
| `generate()` | Generate complete CSS for all animations, transitions, and scroll-driven effects | `config`, `useFirstChild?`, `plugins?` | `string` |
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
@@ -196,21 +196,29 @@ console.log('Interactions removed for hero');
|
|
|
196
196
|
|
|
197
197
|
---
|
|
198
198
|
|
|
199
|
-
## `generate(config,
|
|
199
|
+
## `generate(config, options?)`
|
|
200
200
|
|
|
201
201
|
Generates a complete CSS string from an `InteractConfig`. The output includes `@keyframes`, animation and transition custom properties, view-timeline declarations, state-selector rules, coordinated-list aggregation, and FOUC-prevention initial rules — everything the browser needs to run the configured animations and transitions natively, without waiting for JavaScript.
|
|
202
202
|
|
|
203
203
|
### Signature
|
|
204
204
|
|
|
205
205
|
```typescript
|
|
206
|
-
function generate(config: InteractConfig,
|
|
206
|
+
function generate(config: InteractConfig, options?: boolean | GenerateOptions): string;
|
|
207
|
+
|
|
208
|
+
type GenerateOptions = {
|
|
209
|
+
useFirstChild?: boolean;
|
|
210
|
+
plugins?: InteractPluginStyles;
|
|
211
|
+
};
|
|
207
212
|
```
|
|
208
213
|
|
|
209
214
|
### Parameters
|
|
210
215
|
|
|
211
216
|
**`config: InteractConfig`** - The full interaction configuration. Every interaction in the config is processed — not just `viewEnter`.
|
|
212
217
|
|
|
213
|
-
**`
|
|
218
|
+
**`options?: boolean | GenerateOptions`** - Either an options object or — for backwards compatibility — a bare boolean used as `useFirstChild` (`generate(config, false)` ≡ `generate(config, { useFirstChild: false })`).
|
|
219
|
+
|
|
220
|
+
- **`useFirstChild?: boolean`** - When `true` (the default), generated selectors target the first child of each keyed element (e.g. `[data-interact-key="hero"] > :first-child`). This is the correct mode for `<interact-element>` custom elements. Pass `false` when the keyed element itself is the animation target (vanilla JS or React `<Interaction>`).
|
|
221
|
+
- **`plugins?: InteractPluginStyles`** - Optional map of plugin name → SSR style generator. For every `$<name>` field in the config, the matching generator is called with the field's (opaque) value and a context, and its returned CSS data is appended to the output. Used to emit build-time styling on a plugin's behalf — e.g. hiding pre-split text for FOUC prevention. Like `create()`/`use()`, `generate()` never inspects the field value. See [Plugins → SSR styling](../guides/plugins.md#ssr-styling-foouc-prevention).
|
|
214
222
|
|
|
215
223
|
### Returns
|
|
216
224
|
|
|
@@ -31,6 +31,9 @@ class Interact {
|
|
|
31
31
|
}): void;
|
|
32
32
|
static registerEffects(effects: Record<string, NamedEffect>): void;
|
|
33
33
|
static getController(key: string | undefined): IInteractionController | undefined;
|
|
34
|
+
static use(name: string, plugin: InteractPlugin): void;
|
|
35
|
+
static getPlugin(name: string): InteractPlugin | undefined;
|
|
36
|
+
static getPluginNames(): Set<string>;
|
|
34
37
|
|
|
35
38
|
// Instance methods
|
|
36
39
|
init(config: InteractConfig, options?: { useCustomElement?: boolean }): void;
|
|
@@ -230,6 +233,38 @@ Interact.registerEffects({
|
|
|
230
233
|
- Effects must be registered before calling `Interact.create()` with configurations that reference them
|
|
231
234
|
- Registration is global — once registered, effects are available to all Interact instances
|
|
232
235
|
|
|
236
|
+
### `Interact.use(name, plugin)`
|
|
237
|
+
|
|
238
|
+
Registers a plugin under a name. When an interaction or effect carries a `$<name>` field, Interact invokes the plugin with that field's value and a context. Interact is agnostic to what the plugin does — see the [Plugins guide](../guides/plugins.md).
|
|
239
|
+
|
|
240
|
+
**Parameters:**
|
|
241
|
+
|
|
242
|
+
- `name: string` - The plugin name, matched against `$<name>` config fields
|
|
243
|
+
- `plugin: InteractPlugin` - `(value, context) => void | (() => void)`; the returned cleanup runs on disconnect/teardown
|
|
244
|
+
|
|
245
|
+
**Example:**
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { Interact } from '@wix/interact';
|
|
249
|
+
import { splitTextPlugin } from '@wix/splittext/plugin';
|
|
250
|
+
|
|
251
|
+
Interact.use('splitText', splitTextPlugin);
|
|
252
|
+
Interact.create(config); // configs may now use a `$splitText: { ... }` field
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Notes:**
|
|
256
|
+
|
|
257
|
+
- Register plugins **before** `Interact.create()`.
|
|
258
|
+
- Registration is global. A `$<name>` field naming an unregistered plugin is ignored.
|
|
259
|
+
|
|
260
|
+
### `Interact.getPlugin(name)`
|
|
261
|
+
|
|
262
|
+
Returns the plugin registered under `name`, or `undefined`.
|
|
263
|
+
|
|
264
|
+
### `Interact.getPluginsNames()`
|
|
265
|
+
|
|
266
|
+
Returns the set of registered plugins names (non-prefixed).
|
|
267
|
+
|
|
233
268
|
### `Interact.getController(key)`
|
|
234
269
|
|
|
235
270
|
Retrieves a cached `InteractionController` by its key.
|
package/docs/api/types.md
CHANGED
|
@@ -117,7 +117,7 @@ type Interaction = {
|
|
|
117
117
|
params?: TriggerParams;
|
|
118
118
|
conditions?: string[];
|
|
119
119
|
effects: ((Effect | EffectRef) & { interactionId?: string })[];
|
|
120
|
-
};
|
|
120
|
+
} & PluginFields; // `$<name>` plugin fields, e.g. `$splitText`
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
**Properties:**
|
|
@@ -128,6 +128,7 @@ type Interaction = {
|
|
|
128
128
|
- `listContainer` - Optional selector for list container when targeting list items
|
|
129
129
|
- `params` - Optional parameters for the trigger
|
|
130
130
|
- `conditions` - Optional array of condition IDs to evaluate
|
|
131
|
+
- `$<name>` - Optional `$`-prefixed plugin fields (see [Plugin Types](#plugin-types)). Also available on effects.
|
|
131
132
|
- `effects` - Array of effects to apply when triggered
|
|
132
133
|
|
|
133
134
|
**Example:**
|
|
@@ -615,6 +616,7 @@ type TransitionProperty = StyleProperty & TransitionOptions;
|
|
|
615
616
|
|
|
616
617
|
**Properties:**
|
|
617
618
|
|
|
619
|
+
- `name` - CSS property name, in kebab-case (`'background-color'`) or camelCase (`'backgroundColor'`). Both are accepted and normalized to kebab-case in the generated CSS; custom properties (`--*`) are used verbatim and are case-sensitive.
|
|
618
620
|
- `stateAction` - How to modify the element's CSS state on event triggers (`hover`, `click`, `activate`, `interest`):
|
|
619
621
|
- `'toggle'` (default) - Hover: adds on enter, removes on leave. Click: toggles on each click.
|
|
620
622
|
- `'add'` - Add the effect state; hover leave will NOT auto-remove.
|
|
@@ -937,6 +939,96 @@ Union type of all trigger parameter types.
|
|
|
937
939
|
type TriggerParams = ViewEnterParams | PointerMoveParams | AnimationEndParams;
|
|
938
940
|
```
|
|
939
941
|
|
|
942
|
+
## Plugin Types
|
|
943
|
+
|
|
944
|
+
See the [Plugins guide](../guides/plugins.md) for the full picture.
|
|
945
|
+
|
|
946
|
+
### `InteractPlugin`
|
|
947
|
+
|
|
948
|
+
A plugin callback registered via `Interact.use()`.
|
|
949
|
+
|
|
950
|
+
```typescript
|
|
951
|
+
type InteractPlugin = (
|
|
952
|
+
value: unknown,
|
|
953
|
+
context: InteractPluginContext,
|
|
954
|
+
) => void | InteractPluginCleanup;
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
### `InteractPluginContext`
|
|
958
|
+
|
|
959
|
+
```typescript
|
|
960
|
+
type InteractPluginContext = {
|
|
961
|
+
root: HTMLElement; // the interaction's (or effect target's) root element
|
|
962
|
+
key: string; // the interaction/effect key
|
|
963
|
+
scope: 'interaction' | 'effect';
|
|
964
|
+
config: Record<string, unknown>; // the interaction/effect object the plugin field was on
|
|
965
|
+
};
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
### `InteractPluginCleanup`
|
|
969
|
+
|
|
970
|
+
```typescript
|
|
971
|
+
type InteractPluginCleanup = () => void; // runs on disconnect/teardown
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
### `InteractPluginConfigMap`
|
|
975
|
+
|
|
976
|
+
Augmentable interface for typing plugin fields, keyed by the **unprefixed** plugin name. Empty by default; consumers merge into it:
|
|
977
|
+
|
|
978
|
+
```typescript
|
|
979
|
+
import type { SplitTextPluginConfig } from '@wix/splittext/plugin';
|
|
980
|
+
|
|
981
|
+
declare module '@wix/interact' {
|
|
982
|
+
interface InteractPluginConfigMap {
|
|
983
|
+
splitText: SplitTextPluginConfig;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
// types the `$splitText` field on interactions and effects
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
Prefer the config type exported by the plugin package over re-declaring its shape by hand.
|
|
990
|
+
|
|
991
|
+
### `PluginFields`
|
|
992
|
+
|
|
993
|
+
The `$`-prefixed plugin fields allowed on interactions and effects. Augmented plugins keep their value types (as `$<name>`); any other `$`-prefixed field is still allowed with an `unknown` value.
|
|
994
|
+
|
|
995
|
+
```typescript
|
|
996
|
+
type PluginFields = {
|
|
997
|
+
[K in keyof InteractPluginConfigMap as `$${K & string}`]?: InteractPluginConfigMap[K];
|
|
998
|
+
} & {
|
|
999
|
+
[pluginField: `$${string}`]: unknown;
|
|
1000
|
+
};
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
### `InteractPluginStyleGenerator`
|
|
1004
|
+
|
|
1005
|
+
A plugin's **build-time** styling callback, passed in the `plugins` argument of `generate()` (distinct from the runtime callback given to `Interact.use()`). Returns initial CSS declarations for the element — e.g. hiding pre-plugin content for FOUC prevention.
|
|
1006
|
+
|
|
1007
|
+
```typescript
|
|
1008
|
+
type InteractPluginStyleGenerator = (
|
|
1009
|
+
value: unknown,
|
|
1010
|
+
context: InteractPluginStyleContext,
|
|
1011
|
+
) => { declarations: { name: string; value: string | number }[]; selectorSuffix?: string }[];
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
### `InteractPluginStyleContext`
|
|
1015
|
+
|
|
1016
|
+
```typescript
|
|
1017
|
+
type InteractPluginStyleContext = {
|
|
1018
|
+
key: string; // the interaction (or effect target) key the field is on
|
|
1019
|
+
scope: 'interaction' | 'effect';
|
|
1020
|
+
config: Record<string, unknown>; // the interaction/effect object the field is on
|
|
1021
|
+
};
|
|
1022
|
+
```
|
|
1023
|
+
|
|
1024
|
+
### `InteractPluginStyles`
|
|
1025
|
+
|
|
1026
|
+
Map of plugin name → SSR style generator, passed as the `plugins` argument to `generate()`.
|
|
1027
|
+
|
|
1028
|
+
```typescript
|
|
1029
|
+
type InteractPluginStyles = Record<string, InteractPluginStyleGenerator>;
|
|
1030
|
+
```
|
|
1031
|
+
|
|
940
1032
|
## See Also
|
|
941
1033
|
|
|
942
1034
|
- [Sequences & Staggering Guide](../guides/sequences.md) - Comprehensive sequences guide
|
package/docs/guides/README.md
CHANGED
|
@@ -40,6 +40,10 @@ Working with dynamic lists, list containers, staggered animations, and automatic
|
|
|
40
40
|
|
|
41
41
|
Coordinate multiple effects with staggered timing using easing-driven delay offsets. Covers inline and reusable sequences, cross-element orchestration, `listContainer` integration, dynamic add/remove, and conditional sequences.
|
|
42
42
|
|
|
43
|
+
### 🔌 [Plugins](./plugins.md)
|
|
44
|
+
|
|
45
|
+
Extend Interact with external code via `Interact.use()` and `$`-prefixed config fields. Covers the generic bridge, the plugin contract and cleanup lifecycle, type-safe config, and using `@wix/splittext` to split text for staggered reveals.
|
|
46
|
+
|
|
43
47
|
## Learning Path
|
|
44
48
|
|
|
45
49
|
If you're new to `@wix/interact`, we recommend following the guides in this order:
|
|
@@ -43,6 +43,8 @@ Each interaction defines a complete cause-and-effect relationship:
|
|
|
43
43
|
|
|
44
44
|
Time-based playback (`once`, `repeat`, `alternate`, `state`) is set with `triggerType` on each time effect, or with `triggerType` on a sequence object when using `sequences`. Optional `params` on the interaction are for observer options (`viewEnter`), pointer/`animationEnd` settings, and other non-playback trigger configuration.
|
|
45
45
|
|
|
46
|
+
An interaction (or effect) may also carry `$`-prefixed fields (e.g. `$splitText`) — config routed to external plugins registered via `Interact.use()`. See the [Plugins guide](./plugins.md).
|
|
47
|
+
|
|
46
48
|
## Element Selection with Selectors
|
|
47
49
|
|
|
48
50
|
The `selector` property allows you to specify exactly which element should be used for interactions, instead of being limited to the first child element.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Plugins
|
|
2
|
+
|
|
3
|
+
`@wix/interact` can route parts of your config to **plugins** — external code registered at runtime. Interact acts purely as a bridge: it knows a plugin's _name_, and when an interaction or effect carries a field named `$<name>` it hands that field's value to the plugin. Interact never knows what the plugin does.
|
|
4
|
+
|
|
5
|
+
This keeps Interact free of any plugin-specific code, and keeps plugins (like [`@wix/splittext`](https://www.npmjs.com/package/@wix/splittext)) free of any dependency on Interact. A plugin package can still ship its own adapter — `@wix/splittext/plugin` does — by typing it _structurally_ against the contract below rather than importing `@wix/interact`. Your app then only supplies the type glue.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
1. Register a plugin by name, before `Interact.create()`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Interact } from '@wix/interact';
|
|
13
|
+
|
|
14
|
+
Interact.use('myPlugin', (value, context) => {
|
|
15
|
+
// `value` is whatever the config put in the `$myPlugin` field
|
|
16
|
+
// `context` describes where it was found (see below)
|
|
17
|
+
// return an optional cleanup function
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Reference it with a `$`-prefixed field on an **interaction** or an **effect**:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
Interact.create({
|
|
25
|
+
interactions: [
|
|
26
|
+
{
|
|
27
|
+
key: 'hero',
|
|
28
|
+
trigger: 'viewEnter',
|
|
29
|
+
$myPlugin: { any: 'value' },
|
|
30
|
+
effects: [{ effectId: 'fade-in' }],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
When the `hero` element connects, Interact sees the `$myPlugin` field, looks up the `myPlugin` plugin, and calls it with `{ any: 'value' }`. Plugins run **before** target resolution, so any DOM a plugin creates is visible to the `selector` / `listContainer` queries that follow.
|
|
37
|
+
|
|
38
|
+
If a `$`-prefixed field names a plugin that was never registered, Interact ignores it.
|
|
39
|
+
|
|
40
|
+
> **Why the `$` prefix?** It marks a field as plugin config unambiguously (no clash with real config fields), it's a valid unquoted key in JS/TS and valid JSON, and it lets `@wix/interact-validate` accept plugin fields (via `catchall`) while still flagging genuinely-unknown keys.
|
|
41
|
+
|
|
42
|
+
## The plugin contract
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
type InteractPlugin = (
|
|
46
|
+
value: unknown,
|
|
47
|
+
context: {
|
|
48
|
+
root: HTMLElement; // the interaction's (or effect target's) root element
|
|
49
|
+
key: string; // the interaction/effect key
|
|
50
|
+
scope: 'interaction' | 'effect';
|
|
51
|
+
config: Record<string, unknown>; // the interaction/effect object the field was on
|
|
52
|
+
},
|
|
53
|
+
) => void | (() => void); // optionally return a cleanup function
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- Plugins run at **connect** time (when the element enters the DOM / is added).
|
|
57
|
+
- A returned **cleanup** runs on disconnect, on teardown (`Interact.destroy()`), and when an interaction re-connects after a media-query change — so plugins can fully undo their work.
|
|
58
|
+
- Each distinct plugin value is applied **once per connect**, even if referenced by multiple triggers on the same element.
|
|
59
|
+
|
|
60
|
+
### Type-safe config (optional)
|
|
61
|
+
|
|
62
|
+
Augment `InteractPluginConfigMap` — keyed by the **unprefixed** plugin name — so the `$<name>` field is type-checked:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
declare module '@wix/interact' {
|
|
66
|
+
interface InteractPluginConfigMap {
|
|
67
|
+
myPlugin: { any: string };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// now `$myPlugin` is typed as `{ any: string }` on interactions and effects
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Example: `@wix/splittext`
|
|
74
|
+
|
|
75
|
+
`@wix/splittext` splits an element's text into `<span>` wrappers (`.split-c` for chars, `.split-w` for words, `.split-l` for lines, `.split-s` for sentences). You don't need to write the adapter — it ships from the `@wix/splittext/plugin` entry point, written against the contract above _structurally_ so `@wix/splittext` keeps no dependency on `@wix/interact`. Register it, then target the generated spans with a normal `selector`:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
// splitTextTypes.ts — the ONLY module that needs both packages, and only for types
|
|
79
|
+
import type { SplitTextPluginConfig } from '@wix/splittext/plugin';
|
|
80
|
+
|
|
81
|
+
declare module '@wix/interact' {
|
|
82
|
+
interface InteractPluginConfigMap {
|
|
83
|
+
splitText: SplitTextPluginConfig;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { Interact } from '@wix/interact';
|
|
90
|
+
import { splitTextPlugin } from '@wix/splittext/plugin';
|
|
91
|
+
|
|
92
|
+
Interact.use('splitText', splitTextPlugin);
|
|
93
|
+
|
|
94
|
+
Interact.create({
|
|
95
|
+
effects: {
|
|
96
|
+
'char-fade-up': { namedEffect: { type: 'FadeIn' }, duration: 400 },
|
|
97
|
+
},
|
|
98
|
+
interactions: [
|
|
99
|
+
{
|
|
100
|
+
key: 'hero',
|
|
101
|
+
trigger: 'viewEnter',
|
|
102
|
+
// split `.title` into characters before the sequence resolves
|
|
103
|
+
$splitText: { container: '.title', type: 'chars' },
|
|
104
|
+
sequences: [
|
|
105
|
+
{
|
|
106
|
+
offset: 30,
|
|
107
|
+
offsetEasing: 'quadIn',
|
|
108
|
+
// stagger the generated char spans
|
|
109
|
+
effects: [{ effectId: 'char-fade-up', selector: '.split-c' }],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Effect-level (cross-element) splitting
|
|
118
|
+
|
|
119
|
+
A `$`-prefixed field can also sit on an individual effect, using that effect's **target** element as the root — useful for splitting a different element inside a multi-effect sequence:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
{
|
|
123
|
+
key: 'cta',
|
|
124
|
+
trigger: 'click',
|
|
125
|
+
sequences: [
|
|
126
|
+
{
|
|
127
|
+
offset: 60,
|
|
128
|
+
effects: [
|
|
129
|
+
{
|
|
130
|
+
key: 'heading',
|
|
131
|
+
$splitText: { container: '.heading-text', type: 'chars' },
|
|
132
|
+
selector: '.split-c',
|
|
133
|
+
effectId: 'scatter',
|
|
134
|
+
},
|
|
135
|
+
{ key: 'subtitle', effectId: 'fade-out' },
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## SSR styling (FOUC prevention)
|
|
143
|
+
|
|
144
|
+
A plugin often needs initial CSS _before_ it runs — e.g. hiding the un-split text so an entrance animation doesn't flash the raw content. That's a build-time concern, so it lives in [`generate()`](../api/functions.md#generateconfig-options), not in the runtime `use()` callback.
|
|
145
|
+
|
|
146
|
+
Pass a **second, separate callback per plugin** in the `plugins` option of `generate()`'s options bag — `generate(config, { useFirstChild, plugins })`. For every `$<name>` field, `generate()` calls the matching generator with the field's (opaque) value and a context, and appends the returned CSS. Like `create()`, `generate()` never looks inside the value — the plugin decides what to emit (and defines its own selectors under `selectorSuffix`).
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
type InteractPluginStyleGenerator = (
|
|
150
|
+
value: unknown,
|
|
151
|
+
context: {
|
|
152
|
+
key: string;
|
|
153
|
+
scope: 'interaction' | 'effect';
|
|
154
|
+
config: Record<string, unknown>;
|
|
155
|
+
},
|
|
156
|
+
) => { declarations: { name: string; value: string | number }[]; selectorSuffix?: string }[];
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`selectorSuffix` is concatenated to the base selector (`[data-interact-key="<key>"]`), to refine the target for the styling.
|
|
160
|
+
|
|
161
|
+
### SplitText example — hide until split
|
|
162
|
+
|
|
163
|
+
`@wix/splittext/plugin` ships this pairing ready-made: `splitTextStyle` is the SSR counterpart to `splitTextPlugin`, and the two agree on a `data-splittext-ready` marker. Opt in per-field with `hideUntilReady`:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
import { generate } from '@wix/interact';
|
|
167
|
+
import { splitTextStyle } from '@wix/splittext/plugin';
|
|
168
|
+
|
|
169
|
+
const config = {
|
|
170
|
+
effects: { 'char-fade-up': { namedEffect: { type: 'FadeIn' }, duration: 400 } },
|
|
171
|
+
interactions: [
|
|
172
|
+
{
|
|
173
|
+
key: 'hero',
|
|
174
|
+
trigger: 'viewEnter',
|
|
175
|
+
$splitText: { container: '.title', type: 'chars', hideUntilReady: true },
|
|
176
|
+
sequences: [{ offset: 30, effects: [{ effectId: 'char-fade-up', selector: '.split-c' }] }],
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// Embed this CSS in <head> at build/SSR time.
|
|
182
|
+
const css = generate(config, { plugins: { splitText: splitTextStyle } });
|
|
183
|
+
// → `[data-interact-key="hero"] .title:not([data-splittext-ready]) { visibility: hidden; }`
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
On first paint the container is hidden; once the runtime plugin splits it and sets `data-splittext-ready`, the hide rule stops matching and the (individually-hidden) spans take over their entrance animation — no flash of un-split text. Without `hideUntilReady`, `splitTextStyle` emits nothing.
|
|
187
|
+
|
|
188
|
+
> Plugin styles are emitted verbatim and unconditionally. If a rule should be scoped to a media query or condition, have the generator build that itself (it receives the interaction/effect `config`).
|
|
189
|
+
|
|
190
|
+
## Validation
|
|
191
|
+
|
|
192
|
+
`@wix/interact-validate` accepts any `$`-prefixed field as opaque plugin config (via zod's `catchall`) — it does not inspect plugin-specific shapes (it has no knowledge of any plugin). Non-prefixed unknown keys are still rejected, so a typo like `slector` (or forgetting the `$` on a plugin field) is caught.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/interact",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
4
4
|
"description": "Declarative, configuration-driven interaction library — web-native, AI-ready, and framework-agnostic.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"url": "https://github.com/wix/interact/issues"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@wix/motion": "^2.1.
|
|
71
|
+
"@wix/motion": "^2.1.9",
|
|
72
72
|
"fastdom": "^1.0.12",
|
|
73
73
|
"fizban": "^0.7.2",
|
|
74
74
|
"kuliso": "^0.4.13"
|
package/rules/click.md
CHANGED
|
@@ -67,7 +67,7 @@ Use `keyframeEffect` or `namedEffect` when the click should play an animation (C
|
|
|
67
67
|
- `'repeat'` — restarts the animation from the beginning on each click.
|
|
68
68
|
- `'once'` — plays once on the first click and never again.
|
|
69
69
|
- `'state'` — resumes/pauses the animation on each click. Useful for continuous loops (`iterations: Infinity`).
|
|
70
|
-
- `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names
|
|
70
|
+
- `[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.
|
|
71
71
|
- `[EFFECT_NAME]` — unique string identifier for a `keyframeEffect`.
|
|
72
72
|
- `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built, time-based animation effect from `@wix/motion-presets`. Refer to motion-presets rules for available presets and their options.
|
|
73
73
|
- `[FILL_MODE]` - optional. Always `'both'` with `triggerType: 'alternate'` or `'repeat'`, otherwise depends on the effect.
|
|
@@ -130,7 +130,7 @@ Use `transition` when all properties share timing. Use `transitionProperties` wh
|
|
|
130
130
|
- `'add'` — applies the style state. Does not remove on subsequent clicks.
|
|
131
131
|
- `'remove'` — removes a previously applied style state.
|
|
132
132
|
- `'clear'` — clears all previously applied style states. Useful for resetting multiple stacked style states at once.
|
|
133
|
-
- `[CSS_PROP]` — CSS property name as a string in
|
|
133
|
+
- `[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.
|
|
134
134
|
- `[VALUE]` — target CSS value for the property.
|
|
135
135
|
- `[DURATION_MS]` — transition duration in milliseconds.
|
|
136
136
|
- `[DELAY_MS]` — optional transition delay in milliseconds.
|
package/rules/full-lean.md
CHANGED
|
@@ -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
|
---
|
|
@@ -468,7 +469,7 @@ Used with `hover` / `click` triggers. Set `stateAction` on the effect to control
|
|
|
468
469
|
}
|
|
469
470
|
```
|
|
470
471
|
|
|
471
|
-
CSS property names
|
|
472
|
+
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
473
|
|
|
473
474
|
### Animation Payloads
|
|
474
475
|
|
|
@@ -504,7 +505,7 @@ Exactly one MUST be provided per time-based or scroll/pointer-driven effect:
|
|
|
504
505
|
```
|
|
505
506
|
|
|
506
507
|
- `[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
|
|
508
|
+
- `[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
509
|
|
|
509
510
|
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
511
|
|
|
@@ -705,17 +706,62 @@ The target element is what the effect animates. Resolved in priority order:
|
|
|
705
706
|
|
|
706
707
|
---
|
|
707
708
|
|
|
709
|
+
## Plugins
|
|
710
|
+
|
|
711
|
+
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.
|
|
712
|
+
|
|
713
|
+
- Register before `create()`: `Interact.use('splitText', splitTextPlugin)`.
|
|
714
|
+
- Reference with a `$<name>` field on an **interaction** or **effect**: `$splitText: { container: '.title', type: 'chars' }`.
|
|
715
|
+
- Plugins run at connect time, **before** target resolution — so DOM they create (e.g. `.split-c` spans) is visible to `selector` queries that follow.
|
|
716
|
+
- A plugin may return a cleanup function; Interact runs it on disconnect/teardown.
|
|
717
|
+
- A `$<name>` field with no registered plugin is ignored.
|
|
718
|
+
- Plugin fields MUST be `$`-prefixed — a non-prefixed unknown key on an interaction/effect is rejected by `@wix/interact-validate`.
|
|
719
|
+
- **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.
|
|
720
|
+
|
|
721
|
+
**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:
|
|
722
|
+
|
|
723
|
+
```js
|
|
724
|
+
import { Interact, generate } from '@wix/interact';
|
|
725
|
+
import { splitTextPlugin, splitTextStyle } from '@wix/splittext/plugin';
|
|
726
|
+
|
|
727
|
+
const config = {
|
|
728
|
+
effects: { 'char-fade-up': { namedEffect: { type: 'FadeIn' }, duration: 400 } },
|
|
729
|
+
interactions: [
|
|
730
|
+
{
|
|
731
|
+
key: 'hero',
|
|
732
|
+
trigger: 'viewEnter',
|
|
733
|
+
// `hideUntilReady` opts into the SSR hide rule emitted by splitTextStyle
|
|
734
|
+
$splitText: { container: '.title', type: 'chars', hideUntilReady: true },
|
|
735
|
+
sequences: [{ offset: 30, effects: [{ effectId: 'char-fade-up', selector: '.split-c' }] }],
|
|
736
|
+
},
|
|
737
|
+
],
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
const css = generate(config, { useFirstChild: true, plugins: { splitText: splitTextStyle } });
|
|
741
|
+
// Embed css in HTML — see CSS Generation & FOUC Prevention
|
|
742
|
+
|
|
743
|
+
Interact.use('splitText', splitTextPlugin);
|
|
744
|
+
|
|
745
|
+
Interact.create(config);
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
- `$splitText` takes `{ container, hideUntilReady?, ...SplitTextOptions }`; `container` is resolved within the element and every match is split.
|
|
749
|
+
- Type the field in your app: `declare module '@wix/interact' { interface InteractPluginConfigMap { splitText: SplitTextPluginConfig } }` (type from `@wix/splittext/plugin`).
|
|
750
|
+
|
|
751
|
+
Default split wrapper classes: `.split-c` (chars), `.split-w` (words), `.split-l` (lines), `.split-s` (sentences).
|
|
752
|
+
|
|
708
753
|
## Static API
|
|
709
754
|
|
|
710
|
-
| Method / Property | Description
|
|
711
|
-
| :---------------------------------- |
|
|
712
|
-
| `generate(config,
|
|
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.
|
|
755
|
+
| Method / Property | Description |
|
|
756
|
+
| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
757
|
+
| `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)). |
|
|
758
|
+
| `Interact.create(config)` | Initialize with a config. Returns the instance. Store the instance to manage its lifecycle. |
|
|
759
|
+
| `Interact.registerEffects(presets)` | Register named effect presets. MUST be called before `generate()` and `create`. |
|
|
760
|
+
| `Interact.destroy()` | Tear down all instances. Call on unmount or route change to prevent memory leaks. |
|
|
761
|
+
| `Interact.forceReducedMotion` | `boolean` (default: `false`) — force reduced-motion behavior regardless of OS setting. |
|
|
762
|
+
| `Interact.allowA11yTriggers` | `boolean` (default: `true`) — enable accessibility trigger variants (`interest`, `activate`). |
|
|
763
|
+
| `Interact.setup(options)` | Configure global options for scroll, pointer, and viewEnter systems. Call before `create`. See options below. |
|
|
764
|
+
| `Interact.use(name, plugin)` | Register an external plugin by name (see [Plugins](#plugins)). Call before `create`. |
|
|
719
765
|
|
|
720
766
|
**`Interact.setup(options)`** — optional configuration object:
|
|
721
767
|
|
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
|
|
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
|
|
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.
|