@wix/interact 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react.js +1 -1
- package/dist/cjs/web.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/react.js +2 -2
- package/dist/es/web.js +2 -2
- package/dist/{index-76zNBcNy.mjs → index-Bn1cDv1F.mjs} +1652 -1465
- package/dist/index-Bn1cDv1F.mjs.map +1 -0
- package/dist/index-bjIzuPaD.js +29 -0
- package/dist/index-bjIzuPaD.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/core/Interact.d.ts +15 -15
- package/dist/types/core/Interact.d.ts.map +1 -1
- package/dist/types/core/add.d.ts.map +1 -1
- package/dist/types/core/css.d.ts +1 -1
- package/dist/types/core/css.d.ts.map +1 -1
- package/dist/types/core/reducedMotion.d.ts +21 -0
- package/dist/types/core/reducedMotion.d.ts.map +1 -0
- package/dist/types/core/resolvers.d.ts +3 -3
- package/dist/types/core/resolvers.d.ts.map +1 -1
- package/dist/types/handlers/animationEnd.d.ts +1 -1
- package/dist/types/handlers/animationEnd.d.ts.map +1 -1
- package/dist/types/handlers/effectHandlers.d.ts +2 -2
- package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
- package/dist/types/handlers/eventTrigger.d.ts +1 -1
- package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
- package/dist/types/handlers/pointerMove.d.ts +1 -1
- package/dist/types/handlers/pointerMove.d.ts.map +1 -1
- package/dist/types/handlers/viewEnter.d.ts +1 -1
- package/dist/types/handlers/viewEnter.d.ts.map +1 -1
- package/dist/types/handlers/viewProgress.d.ts +1 -1
- package/dist/types/handlers/viewProgress.d.ts.map +1 -1
- package/dist/types/types/config.d.ts +6 -1
- package/dist/types/types/config.d.ts.map +1 -1
- package/dist/types/types/css.d.ts +26 -0
- package/dist/types/types/css.d.ts.map +1 -1
- package/dist/types/types/effects.d.ts +2 -0
- package/dist/types/types/effects.d.ts.map +1 -1
- package/dist/types/types/handlers.d.ts +4 -1
- package/dist/types/types/handlers.d.ts.map +1 -1
- package/dist/types/types/internal.d.ts +3 -1
- package/dist/types/types/internal.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/api/interact-class.md +16 -2
- package/docs/api/types.md +21 -3
- package/docs/guides/conditions-and-media-queries.md +53 -0
- package/package.json +1 -1
- package/rules/full-lean.md +30 -3
- package/rules/integration.md +2 -2
- package/rules/validate.md +47 -38
- package/dist/index-76zNBcNy.mjs.map +0 -1
- package/dist/index-BMJFenGC.js +0 -29
- package/dist/index-BMJFenGC.js.map +0 -1
|
@@ -7,6 +7,7 @@ type MotionKeyframeEffect = {
|
|
|
7
7
|
};
|
|
8
8
|
export type TimeAnimationTriggerType = 'once' | 'repeat' | 'alternate' | 'state';
|
|
9
9
|
export type StateAction = 'add' | 'remove' | 'toggle' | 'clear';
|
|
10
|
+
export type ReducedMotionPolicy = 'ignore' | 'cancel' | 'collapse' | (string & {});
|
|
10
11
|
type EffectEffectProperty = {
|
|
11
12
|
keyframeEffect: MotionKeyframeEffect;
|
|
12
13
|
} | {
|
|
@@ -65,6 +66,7 @@ export type EffectBase = {
|
|
|
65
66
|
conditions?: string[];
|
|
66
67
|
selector?: string;
|
|
67
68
|
effectId?: string;
|
|
69
|
+
reducedMotionPolicy?: ReducedMotionPolicy;
|
|
68
70
|
} & PluginFields;
|
|
69
71
|
export type EffectRef = EffectBase & {
|
|
70
72
|
effectId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../../src/types/effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,W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MAAM,cAAc,GAAG,KAAK,CAAC;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,EAAE,oBAAoB,CAAC;IACrC,UAAU,EAAE,iBAAiB,GAAG;QAAE,eAAe,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IACrE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC;IAC3C,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;CACzD,CAAC,CAAC"}
|
|
@@ -13,7 +13,6 @@ export type InteractionParamsTypes = {
|
|
|
13
13
|
interest: Record<string, never>;
|
|
14
14
|
};
|
|
15
15
|
export type InteractOptions = {
|
|
16
|
-
reducedMotion?: boolean;
|
|
17
16
|
targetController?: IInteractionController;
|
|
18
17
|
selectorCondition?: string;
|
|
19
18
|
allowA11yTriggers?: boolean;
|
|
@@ -38,4 +37,8 @@ export type HandlerObject = {
|
|
|
38
37
|
handler?: (isIntersecting?: boolean, isFullExit?: boolean) => void;
|
|
39
38
|
};
|
|
40
39
|
export type HandlerObjectMap = WeakMap<HTMLElement, Set<HandlerObject>>;
|
|
40
|
+
export type TimeEffectHandler = {
|
|
41
|
+
handler: (event: Event) => void;
|
|
42
|
+
cleanup: () => void;
|
|
43
|
+
};
|
|
41
44
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/types/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,MAA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,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Effect, EffectRef, StateEffect, TransitionProperty } from './effects';
|
|
1
|
+
import type { Effect, EffectRef, ReducedMotionPolicy, StateEffect, TransitionProperty } from './effects';
|
|
2
2
|
import type { Condition, SequenceConfig, Interaction, InteractionTrigger } from './config';
|
|
3
3
|
export type InteractCache = {
|
|
4
4
|
effects: {
|
|
@@ -10,6 +10,8 @@ export type InteractCache = {
|
|
|
10
10
|
conditions: {
|
|
11
11
|
[conditionId: string]: Condition;
|
|
12
12
|
};
|
|
13
|
+
reducedMotionPolicy?: ReducedMotionPolicy;
|
|
14
|
+
forceReducedMotion?: boolean;
|
|
13
15
|
interactions: {
|
|
14
16
|
[path: string]: {
|
|
15
17
|
triggers: Interaction[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3F,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE;QACP,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;IACF,SAAS,EAAE;QACT,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,CAAC;KACtC,CAAC;IACF,UAAU,EAAE;QACV,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;KAClC,CAAC;IAEF,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,EAAE;QACZ,CAAC,IAAI,EAAE,MAAM,GAAG;YACd,QAAQ,EAAE,WAAW,EAAE,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,kBAAkB,GAAG;gBAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;aAAE,CAAC,EAAE,CAAC,CAAC;YACjF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,kBAAkB,GAAG;gBAAE,QAAQ,EAAE,cAAc,CAAA;aAAE,CAAC,EAAE,CAAC,CAAC;YACjF,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;SACxB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACvC,oBAAoB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC"}
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare function camelToKebabCase(property: string): string;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function applySelectorCondition(baseSelector: string, predicate: string): string;
|
|
11
11
|
export declare function generateId(): string;
|
|
12
|
+
export declare function isTransitionEffect(effect: object): effect is Pick<StateEffect, 'transition' | 'transitionProperties'>;
|
|
12
13
|
/**
|
|
13
14
|
* Resolves the style properties of a state effect - `transition.styleProperties` wins
|
|
14
15
|
* when both are set - with property names normalized to the kebab-case form CSS expects.
|
|
@@ -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,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,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD;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,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B;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"}
|
|
@@ -22,7 +22,12 @@ class Interact {
|
|
|
22
22
|
// Static methods
|
|
23
23
|
static create(
|
|
24
24
|
config: InteractConfig,
|
|
25
|
-
options?: {
|
|
25
|
+
options?: {
|
|
26
|
+
useCustomElement?: boolean;
|
|
27
|
+
configIndex?: number;
|
|
28
|
+
forceReducedMotion?: boolean;
|
|
29
|
+
reducedMotionPolicy?: ReducedMotionPolicy;
|
|
30
|
+
},
|
|
26
31
|
): Interact;
|
|
27
32
|
static getInstance(key: string): Interact | undefined;
|
|
28
33
|
static destroy(): void;
|
|
@@ -31,6 +36,8 @@ class Interact {
|
|
|
31
36
|
pointerOptionsGetter?: () => Partial<PointerConfig>;
|
|
32
37
|
viewEnter?: Partial<ViewEnterParams>;
|
|
33
38
|
allowA11yTriggers?: boolean;
|
|
39
|
+
forceReducedMotion?: boolean;
|
|
40
|
+
reducedMotionPolicy?: ReducedMotionPolicy;
|
|
34
41
|
}): void;
|
|
35
42
|
static registerEffects(effects: Record<string, NamedEffect>): void;
|
|
36
43
|
static getController(key: string | undefined): IInteractionController | undefined;
|
|
@@ -61,6 +68,8 @@ Creates a new `Interact` instance with the provided configuration and initialize
|
|
|
61
68
|
- `config: InteractConfig` - The interaction configuration object
|
|
62
69
|
- `options?.useCustomElement?: boolean` - Whether elements are wrapped in `<interact-element>` (defaults to whether the custom element is available)
|
|
63
70
|
- `options?.configIndex?: number` - The config's index when several configs are on the same page. It must match the `configIndex` passed to [`generate()`](./functions.md#generateconfig-options) for the same config. Unnamed effects and sequences get ids suffixed by it (`eff-c1-0-0`), which become their generated keyframe and state names, so the configs' names don't collide.
|
|
71
|
+
- `options?.forceReducedMotion?: boolean` - Forces reduced motion for this instance, overriding the one set by [`Interact.setup()`](#interactsetupoptions). It must match the `forceReducedMotion` passed to `generate()` for the same config.
|
|
72
|
+
- `options?.reducedMotionPolicy?: ReducedMotionPolicy` - The [`ReducedMotionPolicy`](./types.md#reducedmotionpolicy) of the instance's effects that don't set one on their interaction, sequence or effect, overriding the one set by `Interact.setup()`. It must match the `reducedMotionPolicy` passed to `generate()` for the same config.
|
|
64
73
|
|
|
65
74
|
**Returns:** `Interact` - The initialized interact instance
|
|
66
75
|
|
|
@@ -144,8 +153,10 @@ Configures global settings for the Interact system.
|
|
|
144
153
|
- `options.pointerOptionsGetter` - Optional callback returning default partial pointer config for `pointerMove` trigger
|
|
145
154
|
- `options.viewEnter` - Optional default partial `ViewEnterParams` (e.g. `threshold`, `inset`, `useSafeViewEnter`)
|
|
146
155
|
- `options.allowA11yTriggers` - When `true`, `click` and `hover` triggers also respond to keyboard (Enter/Space) and focus
|
|
156
|
+
- `options.forceReducedMotion` - When `true`, applies the reduced-motion outcome of each effect's `reducedMotionPolicy` regardless of the OS setting (sets `Interact.forceReducedMotion`)
|
|
157
|
+
- `options.reducedMotionPolicy` - The default [`ReducedMotionPolicy`](./types.md#reducedmotionpolicy) of every instance's effects (`'collapse'` unless set; sets `Interact.reducedMotionPolicy`)
|
|
147
158
|
|
|
148
|
-
|
|
159
|
+
Both reduced-motion options can be overridden per instance with `Interact.create(config, options)`. `generate()` defaults to the values set here, so set them before generating, or pass the instance's values to `generate()`.
|
|
149
160
|
|
|
150
161
|
**Example:**
|
|
151
162
|
|
|
@@ -165,6 +176,9 @@ Interact.setup({
|
|
|
165
176
|
}),
|
|
166
177
|
});
|
|
167
178
|
|
|
179
|
+
// Keep effects as they are for users who prefer reduced motion, unless an effect sets its own policy
|
|
180
|
+
Interact.setup({ reducedMotionPolicy: 'ignore' });
|
|
181
|
+
|
|
168
182
|
// Enable accessibility for all click and hover triggers
|
|
169
183
|
Interact.setup({
|
|
170
184
|
allowA11yTriggers: true,
|
package/docs/api/types.md
CHANGED
|
@@ -274,7 +274,6 @@ Options passed to interaction handlers.
|
|
|
274
274
|
|
|
275
275
|
```typescript
|
|
276
276
|
type InteractOptions = {
|
|
277
|
-
reducedMotion?: boolean;
|
|
278
277
|
targetController?: IInteractionController;
|
|
279
278
|
selectorCondition?: string;
|
|
280
279
|
allowA11yTriggers?: boolean;
|
|
@@ -283,7 +282,6 @@ type InteractOptions = {
|
|
|
283
282
|
|
|
284
283
|
**Properties:**
|
|
285
284
|
|
|
286
|
-
- `reducedMotion` - Whether reduced motion is enabled (respects `prefers-reduced-motion` or `Interact.forceReducedMotion`)
|
|
287
285
|
- `targetController` - The controller managing the target element
|
|
288
286
|
- `selectorCondition` - Optional CSS selector condition for element matching
|
|
289
287
|
- `allowA11yTriggers` - Whether to enable accessibility triggers (keyboard events) for `click` and `hover` triggers. When `true`, `click` responds to Enter/Space keys and `hover` responds to focus events. Defaults to `true`.
|
|
@@ -293,7 +291,6 @@ type InteractOptions = {
|
|
|
293
291
|
```typescript
|
|
294
292
|
// Used internally by handlers
|
|
295
293
|
const options: InteractOptions = {
|
|
296
|
-
reducedMotion: Interact.forceReducedMotion,
|
|
297
294
|
targetController: Interact.getController('my-element'),
|
|
298
295
|
};
|
|
299
296
|
```
|
|
@@ -864,6 +861,27 @@ type Interaction = InteractionTrigger & {
|
|
|
864
861
|
|
|
865
862
|
An interaction can have `effects` only, `sequences` only, or both.
|
|
866
863
|
|
|
864
|
+
## Reduced Motion Types
|
|
865
|
+
|
|
866
|
+
### `ReducedMotionPolicy`
|
|
867
|
+
|
|
868
|
+
What an effect does when the user prefers reduced motion: `(prefers-reduced-motion: reduce)` matches, or reduced motion is forced (`forceReducedMotion` of `Interact.setup()` or `Interact.create()`).
|
|
869
|
+
|
|
870
|
+
```typescript
|
|
871
|
+
type ReducedMotionPolicy = 'ignore' | 'cancel' | 'collapse' | (string & {}); // string = effectId
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
Accepted on `Interaction`, `SequenceConfig` / `SequenceConfigRef` and effects, and per instance as an option of `Interact.create()` / `Interact.setup()` (it isn't a config field). The most specific level wins: inline effect → its `effects` registry entry → sequence → interaction → instance → `'collapse'`.
|
|
875
|
+
|
|
876
|
+
- `'collapse'` (default) - Plays with duration 0, keeping everything else (delay, iterations, fill, keyframes), so it jumps to its end state. Transitions become 0ms and keep their delay. Effects with no end state (infinite iterations, `viewProgress` / `pointerMove`) are cancelled instead.
|
|
877
|
+
- `'ignore'` - Plays as usual.
|
|
878
|
+
- `'cancel'` - Dropped, exactly like a `(prefers-reduced-motion: no-preference)` media condition.
|
|
879
|
+
- effectId - Replaced by the animation of `effects[effectId]` (effect type, keyframes and timing), keeping the original's target, conditions, `effectId` and `triggerType`. It must be of the same kind (time, scrub or state) and exist, otherwise the effect collapses.
|
|
880
|
+
|
|
881
|
+
A sequence's stagger (`offset`) collapses to 0 under reduced motion, unless the sequence's own policy resolves to `'ignore'`. Its `delay` and its effects' delays are kept.
|
|
882
|
+
|
|
883
|
+
`generate()` emits both outcomes under exclusive `prefers-reduced-motion` media queries, so the CSS and the runtime agree. `generate()` takes the instance's `reducedMotionPolicy` and `forceReducedMotion` as options, defaulting to the ones set by `Interact.setup()`.
|
|
884
|
+
|
|
867
885
|
## Condition Types
|
|
868
886
|
|
|
869
887
|
### `Condition`
|
|
@@ -269,6 +269,59 @@ const accessibleConfig: InteractConfig = {
|
|
|
269
269
|
};
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
+
### Reduced Motion Policy
|
|
273
|
+
|
|
274
|
+
Instead of writing a separate interaction per motion preference, set `reducedMotionPolicy` and let Interact derive the reduced-motion version of each effect. It is accepted on interactions, sequences and effects — the most specific level wins. By default every effect collapses: it jumps to its end state for users who prefer reduced motion. To change that default, pass `reducedMotionPolicy` to `Interact.setup()` for every instance, or to `Interact.create(config, options)` for one.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
const config: InteractConfig = {
|
|
278
|
+
effects: {
|
|
279
|
+
fade: {
|
|
280
|
+
keyframeEffect: { name: 'fade', keyframes: [{ opacity: '0' }, { opacity: '1' }] },
|
|
281
|
+
duration: 300,
|
|
282
|
+
easing: 'ease-out',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
interactions: [
|
|
287
|
+
{
|
|
288
|
+
key: 'hero-title',
|
|
289
|
+
trigger: 'viewEnter',
|
|
290
|
+
effects: [
|
|
291
|
+
{
|
|
292
|
+
keyframeEffect: {
|
|
293
|
+
name: 'fade-move',
|
|
294
|
+
keyframes: [
|
|
295
|
+
{ opacity: '0', transform: 'translateY(50px) rotate(-2deg)' },
|
|
296
|
+
{ opacity: '1', transform: 'translateY(0) rotate(0deg)' },
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
duration: 800,
|
|
300
|
+
// swap in the subtle `fade` effect instead of collapsing
|
|
301
|
+
reducedMotionPolicy: 'fade',
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
key: 'background',
|
|
307
|
+
trigger: 'viewProgress',
|
|
308
|
+
// drop the parallax entirely
|
|
309
|
+
reducedMotionPolicy: 'cancel',
|
|
310
|
+
effects: [{ namedEffect: { type: 'ParallaxScroll' } }],
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
};
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
- `'collapse'` (default) plays it with duration 0, keeping its iterations, so it jumps to its end state after its delay. Looping and scroll/pointer-driven effects have no end state, so they're cancelled instead.
|
|
317
|
+
- `'ignore'` plays the effect as usual.
|
|
318
|
+
- `'cancel'` drops it, exactly as if it had a `(prefers-reduced-motion: no-preference)` condition.
|
|
319
|
+
- An effectId replaces the effect's animation with that registry effect's, keeping the original target and conditions. It must be the same kind of effect (time-based, scroll/pointer-driven or a state transition), otherwise the effect collapses.
|
|
320
|
+
|
|
321
|
+
A sequence's stagger collapses too, so its items land together, unless the sequence's policy is `'ignore'`.
|
|
322
|
+
|
|
323
|
+
`Interact.setup({ forceReducedMotion: true })` (or `Interact.create(config, { forceReducedMotion: true })` for a single instance) applies the reduced-motion outcome regardless of the user's setting. `generate()` defaults to the values set by `Interact.setup()`; pass it the instance's values otherwise.
|
|
324
|
+
|
|
272
325
|
## Device-Specific Patterns
|
|
273
326
|
|
|
274
327
|
### Touch vs Mouse Devices
|
package/package.json
CHANGED
package/rules/full-lean.md
CHANGED
|
@@ -22,6 +22,7 @@ Declarative configuration-driven interaction library. Binds animations to trigge
|
|
|
22
22
|
- [Animation Payloads](#animation-payloads)
|
|
23
23
|
- [Sequences](#sequences)
|
|
24
24
|
- [Conditions](#conditions)
|
|
25
|
+
- [Reduced Motion](#reduced-motion)
|
|
25
26
|
- [CSS Generation & FOUC Prevention](#css-generation--fouc-prevention)
|
|
26
27
|
- [Element Resolution](#element-resolution)
|
|
27
28
|
- [Plugins](#plugins)
|
|
@@ -39,7 +40,7 @@ Each item here is CRITICAL — ignoring any of them will break animations.
|
|
|
39
40
|
events and flickering. Use `selector` to target a child element, or set the effect's `key` to a different element.
|
|
40
41
|
- **CRITICAL**: For `pointerMove` trigger MUST AVOID using the same element as both source and target with `hitArea: 'self'` and effects that change size or position (e.g. `transform: translate(…)`, `scale(…)`). The transform shifts the hit area, causing jittery re-entry cycles. Instead, use `selector` to target a child element for the animation.
|
|
41
42
|
- **CRITICAL — Do NOT guess preset options**: If you don't know the expected type/structure for a `namedEffect` param, omit it — rely on defaults rather than guessing.
|
|
42
|
-
- **Reduced motion**:
|
|
43
|
+
- **Reduced motion**: Effects collapse by default (see [Reduced Motion](#reduced-motion)) — users who prefer reduced motion get the end state without the tween. Use `'cancel'` to drop an effect, an effectId to swap in a gentler effect, or `'ignore'` to keep it as is. `Interact.setup({ reducedMotionPolicy, forceReducedMotion })` changes the default and forces the reduced outcome for every instance; `Interact.create(config, options)` takes both per instance. Never put `reducedMotionPolicy` on the config root.
|
|
43
44
|
- **Perspective**: Prefer `transform: perspective(...)` inside keyframes. Use the CSS `perspective` property only when multiple children share the same `perspective-origin`.
|
|
44
45
|
|
|
45
46
|
---
|
|
@@ -197,6 +198,7 @@ Each interaction maps a source element + trigger to one or more effects.
|
|
|
197
198
|
effects?: (Effect | EffectRef)[]; // possible to add multiple effects for same trigger
|
|
198
199
|
sequences?: (SequenceConfig | SequenceConfigRef)[]; // possible to add multiple sequences for same trigger
|
|
199
200
|
conditions?: string[]; // ids referencing the top-level conditions map; all must pass
|
|
201
|
+
reducedMotionPolicy?: ReducedMotionPolicy; // default for the interaction's effects
|
|
200
202
|
selector?: string; // optional - CSS selector to refine source element selection within the root element
|
|
201
203
|
listContainer?: string; // optional — CSS selector for list container
|
|
202
204
|
listItemSelector?: string; // optional — CSS selector to filter which children of listContainer are observed as sources
|
|
@@ -361,6 +363,7 @@ Each effect applies a visual change to a target element. An effect is either inl
|
|
|
361
363
|
key?: string; // target element key; omit to target the source
|
|
362
364
|
effectId?: string; // reference to effects registry (EffectRef)
|
|
363
365
|
conditions?: string[]; // ids referencing the top-level conditions map; all must pass
|
|
366
|
+
reducedMotionPolicy?: ReducedMotionPolicy; // see Reduced Motion
|
|
364
367
|
selector?: string; // optional — CSS selector to refine target element
|
|
365
368
|
listContainer?: string; // optional — CSS selector for list container
|
|
366
369
|
listItemSelector?: string; // optional — filter which children of listContainer are selected
|
|
@@ -542,6 +545,7 @@ Coordinate multiple effects with staggered timing. Prefer sequences over manual
|
|
|
542
545
|
sequenceId?: string; // for caching/referencing; also names the CSS stagger custom
|
|
543
546
|
// properties. Defaults to `seq-<interactionIdx>-<sequenceIdx>`
|
|
544
547
|
conditions?: string[]; // ids referencing the top-level conditions map
|
|
548
|
+
reducedMotionPolicy?: ReducedMotionPolicy; // default for the sequence's effects
|
|
545
549
|
}
|
|
546
550
|
```
|
|
547
551
|
|
|
@@ -618,6 +622,27 @@ conditions: {
|
|
|
618
622
|
|
|
619
623
|
---
|
|
620
624
|
|
|
625
|
+
## Reduced Motion
|
|
626
|
+
|
|
627
|
+
```ts
|
|
628
|
+
type ReducedMotionPolicy = 'ignore' | 'cancel' | 'collapse' | string; // string = effectId in the effects registry
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
What an effect does when the user prefers reduced motion (`(prefers-reduced-motion: reduce)`, or forced by `forceReducedMotion` of `Interact.setup()` / `Interact.create()`). Set on an interaction, a sequence or an effect, or per instance (`Interact.setup()` / `Interact.create()` option, not a config field); the most specific wins: effect (inline, then its registry entry) → sequence → interaction → instance → `'collapse'`.
|
|
632
|
+
|
|
633
|
+
| Value | Under reduced motion |
|
|
634
|
+
| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
635
|
+
| `'collapse'` | Default. Plays with duration 0, keeping everything else (delay, iterations, fill, keyframes), so it jumps to its end state. Transitions become 0ms (with delay). Looping and scroll/pointer-driven effects are cancelled. |
|
|
636
|
+
| `'ignore'` | Plays as usual. |
|
|
637
|
+
| `'cancel'` | Dropped, like a `(prefers-reduced-motion: no-preference)` media condition — an earlier effect of the same interaction on the same target may then apply instead. |
|
|
638
|
+
| effectId | Replaced by that registry effect's animation (effect type, keyframes and timing); the original's target, conditions and `triggerType` stay. It must be of the same kind (time, scrub or state) — otherwise it collapses. |
|
|
639
|
+
|
|
640
|
+
- A sequence's stagger (`offset`) collapses to 0, unless the sequence's policy is `'ignore'`; delays are kept.
|
|
641
|
+
- An `animationEnd` source resolves its policy from its registry entry and the instance only — set it there.
|
|
642
|
+
- `generate()` emits both outcomes under exclusive `prefers-reduced-motion` media. It takes the instance's `reducedMotionPolicy` / `forceReducedMotion` as options, defaulting to `Interact.setup()`'s.
|
|
643
|
+
|
|
644
|
+
---
|
|
645
|
+
|
|
621
646
|
## CSS Generation & FOUC Prevention
|
|
622
647
|
|
|
623
648
|
### Generating CSS
|
|
@@ -767,10 +792,10 @@ Default split wrapper classes: `.split-c` (chars), `.split-w` (words), `.split-l
|
|
|
767
792
|
| Method / Property | Description |
|
|
768
793
|
| :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
769
794
|
| `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)`
|
|
795
|
+
| `Interact.create(config, options?)` | Initialize with a config. Returns the instance. Store the instance to manage its lifecycle. `options.forceReducedMotion` / `options.reducedMotionPolicy` override `Interact.setup()`'s for the instance. |
|
|
771
796
|
| `Interact.registerEffects(presets)` | Register named effect presets. MUST be called before `generate()` and `create`. |
|
|
772
797
|
| `Interact.destroy()` | Tear down all instances. Call on unmount or route change to prevent memory leaks. |
|
|
773
|
-
| `Interact.forceReducedMotion` | `boolean` (default: `false`) —
|
|
798
|
+
| `Interact.forceReducedMotion` | `boolean` (default: `false`) — apply the reduced-motion outcome of `reducedMotionPolicy` regardless of OS setting. Set by `Interact.setup()`. |
|
|
774
799
|
| `Interact.allowA11yTriggers` | `boolean` (default: `true`) — enable accessibility trigger variants (`interest`, `activate`). |
|
|
775
800
|
| `Interact.setup(options)` | Configure global options for scroll, pointer, and viewEnter systems. Call before `create`. See options below. |
|
|
776
801
|
| `Interact.use(name, plugin, opts?)` | Register an external plugin by name (see [Plugins](#plugins)). Call before `create`. `opts.defer` defers it until `Interact.ready()`. |
|
|
@@ -784,6 +809,8 @@ Default split wrapper classes: `.split-c` (chars), `.split-w` (words), `.split-l
|
|
|
784
809
|
| `pointerOptionsGetter` | `() => Partial<PointerConfig>` | Function returning defaults for pointer-move animation configuration |
|
|
785
810
|
| `viewEnter` | `Partial<ViewEnterParams>` | Defaults for all viewEnter triggers (`threshold`,`inset`) |
|
|
786
811
|
| `allowA11yTriggers` | `boolean` | Enable accessibility trigger variants (use `interest` and `activate`) |
|
|
812
|
+
| `forceReducedMotion` | `boolean` | Apply the reduced-motion outcome regardless of OS setting |
|
|
813
|
+
| `reducedMotionPolicy` | `ReducedMotionPolicy` | Default policy of effects (default `'collapse'`) |
|
|
787
814
|
|
|
788
815
|
Use `setup()` when you need to override default observer thresholds or provide global configuration that applies to all interactions of a given trigger type.
|
|
789
816
|
|
package/rules/integration.md
CHANGED
|
@@ -363,6 +363,6 @@ Each `Interact.create(config)` call returns an instance. Keep a reference if you
|
|
|
363
363
|
| `Interact.create(config)` | Initialize with a config. Returns the instance. Multiple configs create separate instances. |
|
|
364
364
|
| `Interact.registerEffects(presets)` | Register named effect presets before `generate()` and `create`. Required for `namedEffect`. |
|
|
365
365
|
| `Interact.destroy()` | Tear down all instances. |
|
|
366
|
-
| `Interact.forceReducedMotion` | `boolean` —
|
|
366
|
+
| `Interact.forceReducedMotion` | `boolean` — apply the reduced-motion outcome of `reducedMotionPolicy` regardless of OS setting. Set by `Interact.setup()`, overridable per instance. Default: `false`. |
|
|
367
367
|
| `Interact.allowA11yTriggers` | `boolean` — enable accessibility triggers (`interest`, `activate`). Default: `true`. |
|
|
368
|
-
| `Interact.setup(options)` | Configure global defaults for scroll/pointer/viewEnter trigger params. Call before `create`.
|
|
368
|
+
| `Interact.setup(options)` | Configure global defaults for scroll/pointer/viewEnter trigger params and reduced motion (`forceReducedMotion`, `reducedMotionPolicy`). Call before `create`. |
|
package/rules/validate.md
CHANGED
|
@@ -127,22 +127,23 @@ Severity is one of `'error' | 'warning'`. There are exactly two levers:
|
|
|
127
127
|
1. **`strict: true`** — promotes all remaining issues to `'error'`, so any warning fails the config.
|
|
128
128
|
2. **`severityOverrides`** — keyed by **rule category**, not by individual code. Only the following categories are registered and overridable:
|
|
129
129
|
|
|
130
|
-
| Rule category | Covers codes
|
|
131
|
-
| ------------------------ |
|
|
132
|
-
| `UNUSED_DEFINITION` | `UNUSED_EFFECT`, `UNUSED_SEQUENCE`, `UNUSED_CONDITION`
|
|
133
|
-
| `UNIQUE_DEFINITION_IDS` | `DUPLICATE_KEYFRAME_NAME`
|
|
134
|
-
| `VALID_MEDIA_QUERIES` | `INVALID_MEDIA_QUERY`
|
|
135
|
-
| `SAME_ELEMENT_RETRIGGER` | `SAME_ELEMENT_RETRIGGER`
|
|
136
|
-
| `HIT_AREA_SHIFT` | `HIT_AREA_SHIFT`
|
|
137
|
-
| `ANIMATION_END_GRAPH` | `ANIMATION_END_SELF_REFERENCE`, `ANIMATION_END_CYCLE`
|
|
138
|
-
| `ELEMENT_SELECTION` | `LIST_ITEM_SELECTOR_WITHOUT_CONTAINER`, `REDUNDANT_SELECTOR_WITH_LIST_ITEM`
|
|
139
|
-
| `STATE_EFFECT` | `EMPTY_STYLE_PROPERTIES`, `STATE_REMOVE_WITHOUT_EFFECT_ID`
|
|
140
|
-
| `RECOMMENDED_FILL` | `RECOMMENDED_FILL_BOTH`
|
|
141
|
-
| `POINTER_AXIS` | `POINTER_AXIS_IGNORED`
|
|
142
|
-
| `CSS_PROPERTY_NAME` | `INVALID_CSS_PROPERTY_NAME`
|
|
143
|
-
| `VIEW_INSET` | `INVALID_INSET`
|
|
144
|
-
| `OFFSET_EASING` | `FUNCTION_OFFSET_EASING`
|
|
145
|
-
| `NAMED_EFFECT_PARAMS` | `NAMED_EFFECT_INVALID_PARAM` (error), `NAMED_EFFECT_UNKNOWN_PARAM`
|
|
130
|
+
| Rule category | Covers codes | Default severity |
|
|
131
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
|
|
132
|
+
| `UNUSED_DEFINITION` | `UNUSED_EFFECT`, `UNUSED_SEQUENCE`, `UNUSED_CONDITION` | warning |
|
|
133
|
+
| `UNIQUE_DEFINITION_IDS` | `DUPLICATE_KEYFRAME_NAME` | warning |
|
|
134
|
+
| `VALID_MEDIA_QUERIES` | `INVALID_MEDIA_QUERY` | error |
|
|
135
|
+
| `SAME_ELEMENT_RETRIGGER` | `SAME_ELEMENT_RETRIGGER` | warning |
|
|
136
|
+
| `HIT_AREA_SHIFT` | `HIT_AREA_SHIFT` | warning |
|
|
137
|
+
| `ANIMATION_END_GRAPH` | `ANIMATION_END_SELF_REFERENCE`, `ANIMATION_END_CYCLE` | warning |
|
|
138
|
+
| `ELEMENT_SELECTION` | `LIST_ITEM_SELECTOR_WITHOUT_CONTAINER`, `REDUNDANT_SELECTOR_WITH_LIST_ITEM` | warning |
|
|
139
|
+
| `STATE_EFFECT` | `EMPTY_STYLE_PROPERTIES`, `STATE_REMOVE_WITHOUT_EFFECT_ID` | warning |
|
|
140
|
+
| `RECOMMENDED_FILL` | `RECOMMENDED_FILL_BOTH` | info |
|
|
141
|
+
| `POINTER_AXIS` | `POINTER_AXIS_IGNORED` | warning |
|
|
142
|
+
| `CSS_PROPERTY_NAME` | `INVALID_CSS_PROPERTY_NAME` | warning |
|
|
143
|
+
| `VIEW_INSET` | `INVALID_INSET` | warning |
|
|
144
|
+
| `OFFSET_EASING` | `FUNCTION_OFFSET_EASING` | warning |
|
|
145
|
+
| `NAMED_EFFECT_PARAMS` | `NAMED_EFFECT_INVALID_PARAM` (error), `NAMED_EFFECT_UNKNOWN_PARAM` | warning |
|
|
146
|
+
| `REDUCED_MOTION` | `REDUCED_MOTION_SELF_REFERENCE`, `REDUCED_MOTION_SHADOWED_EFFECT_ID`, `REDUCED_MOTION_ANIMATION_END_SOURCE_MISMATCH`, `REDUCED_MOTION_COLLAPSE_CANCELS` (info) | warning |
|
|
146
147
|
|
|
147
148
|
For each category, set `'off'` to drop those issues entirely, `'warning'` / `'error'` to set their severity:
|
|
148
149
|
|
|
@@ -194,11 +195,13 @@ This is the authoritative list of every code the validator emits today. Codes no
|
|
|
194
195
|
|
|
195
196
|
### Referential errors (severity: error)
|
|
196
197
|
|
|
197
|
-
| Code
|
|
198
|
-
|
|
|
199
|
-
| `ANIMATION_END_EFFECT_NOT_FOUND`
|
|
200
|
-
| `SEQUENCE_ID_NOT_FOUND`
|
|
201
|
-
| `CONDITION_NOT_FOUND`
|
|
198
|
+
| Code | What it flags |
|
|
199
|
+
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
200
|
+
| `ANIMATION_END_EFFECT_NOT_FOUND` | An `animationEnd` interaction's `params.effectId` references a missing effect. |
|
|
201
|
+
| `SEQUENCE_ID_NOT_FOUND` | A `sequenceId` references a key absent from `config.sequences`. |
|
|
202
|
+
| `CONDITION_NOT_FOUND` | A `conditions[]` entry references a key absent from `config.conditions`. |
|
|
203
|
+
| `REDUCED_MOTION_EFFECT_NOT_FOUND` | An effect's `reducedMotionPolicy` names an effectId absent from `config.effects`. On an interaction or sequence it is a **warning** instead — the effects inheriting it collapse. |
|
|
204
|
+
| `REDUCED_MOTION_INCOMPATIBLE_EFFECT` | An effect's `reducedMotionPolicy` names an effect of another kind (time / scroll-or-pointer-driven / state). When inherited from an interaction or sequence it is a **warning** instead — the effect collapses. An effect of a `config.sequences` entry is reported on each sequence reference it inherits from. |
|
|
202
205
|
|
|
203
206
|
### Other structural errors (severity: error)
|
|
204
207
|
|
|
@@ -222,23 +225,29 @@ This is the authoritative list of every code the validator emits today. Codes no
|
|
|
222
225
|
|
|
223
226
|
Statically-detectable authoring pitfalls lifted from the trigger rule files. Each belongs to its own rule category, so `severityOverrides` can silence (`'off'`) or escalate (`'error'`) it. `strict: true` promotes all of these to `error`.
|
|
224
227
|
|
|
225
|
-
| Code
|
|
226
|
-
|
|
|
227
|
-
| `SAME_ELEMENT_RETRIGGER`
|
|
228
|
-
| `HIT_AREA_SHIFT`
|
|
229
|
-
| `ANIMATION_END_SELF_REFERENCE`
|
|
230
|
-
| `LIST_ITEM_SELECTOR_WITHOUT_CONTAINER`
|
|
231
|
-
| `REDUNDANT_SELECTOR_WITH_LIST_ITEM`
|
|
232
|
-
| `EMPTY_STYLE_PROPERTIES`
|
|
233
|
-
| `STATE_REMOVE_WITHOUT_EFFECT_ID`
|
|
234
|
-
| `RECOMMENDED_FILL_BOTH`
|
|
235
|
-
| `RECOMMENDED_FILL_BACKWARDS`
|
|
236
|
-
| `POINTER_AXIS_IGNORED`
|
|
237
|
-
| `INVALID_CSS_PROPERTY_NAME`
|
|
238
|
-
| `INVALID_INSET`
|
|
239
|
-
| `FUNCTION_OFFSET_EASING`
|
|
240
|
-
| `NAMED_EFFECT_INVALID_PARAM`
|
|
241
|
-
| `NAMED_EFFECT_UNKNOWN_PARAM`
|
|
228
|
+
| Code | What it flags | Rule category |
|
|
229
|
+
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------ |
|
|
230
|
+
| `SAME_ELEMENT_RETRIGGER` | `viewEnter` with `triggerType` `repeat`/`alternate`/`state` on the same source+target element (re-trigger loop). | `SAME_ELEMENT_RETRIGGER` |
|
|
231
|
+
| `HIT_AREA_SHIFT` | `hover`/`click`/`interest`/`activate`/`pointerMove` `keyframeEffect` with a `translate`/`scale`/`matrix` transform on the same source+target element. | `HIT_AREA_SHIFT` |
|
|
232
|
+
| `ANIMATION_END_SELF_REFERENCE` | An `animationEnd` interaction waits for an effect it also produces → it can never start. | `ANIMATION_END_GRAPH` |
|
|
233
|
+
| `LIST_ITEM_SELECTOR_WITHOUT_CONTAINER` | `listItemSelector` present without `listContainer` (inert) — on an interaction or an effect. | `ELEMENT_SELECTION` |
|
|
234
|
+
| `REDUNDANT_SELECTOR_WITH_LIST_ITEM` | `selector` is ignored when both `listContainer` and `listItemSelector` are present. | `ELEMENT_SELECTION` |
|
|
235
|
+
| `EMPTY_STYLE_PROPERTIES` | A state effect's `transition.styleProperties` / `transitionProperties` is `[]` (toggles nothing). | `STATE_EFFECT` |
|
|
236
|
+
| `STATE_REMOVE_WITHOUT_EFFECT_ID` | `stateAction: 'remove'` with no `effectId` to pair with a matching `'add'`. | `STATE_EFFECT` |
|
|
237
|
+
| `RECOMMENDED_FILL_BOTH` | A scrubbed (`viewProgress`/`pointerMove`) or toggling (`alternate`/`repeat`/`state`) effect omits `fill: 'both'`. | `RECOMMENDED_FILL` |
|
|
238
|
+
| `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` |
|
|
239
|
+
| `POINTER_AXIS_IGNORED` | `pointerMove` `params.axis` set on a `namedEffect`/`customEffect` (axis only applies to `keyframeEffect`). | `POINTER_AXIS` |
|
|
240
|
+
| `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` |
|
|
241
|
+
| `INVALID_INSET` | `viewEnter` `params.inset` is not 1–4 whitespace-separated CSS lengths/percentages. | `VIEW_INSET` |
|
|
242
|
+
| `FUNCTION_OFFSET_EASING` | A sequence's `offsetEasing` is a function, so `generate()` omits that sequence from the generated CSS. | `OFFSET_EASING` |
|
|
243
|
+
| `NAMED_EFFECT_INVALID_PARAM` | A `namedEffect` param does not match its effect's registered `schema` (type, enum values, min/max, length/angle format). | `NAMED_EFFECT_PARAMS` |
|
|
244
|
+
| `NAMED_EFFECT_UNKNOWN_PARAM` | A `namedEffect` param is not declared in its effect's registered `schema` (e.g. a renamed param). | `NAMED_EFFECT_PARAMS` |
|
|
245
|
+
| `REDUCED_MOTION_SELF_REFERENCE` | An effect's `reducedMotionPolicy` names the effect itself, which is the same as `'ignore'`. | `REDUCED_MOTION` |
|
|
246
|
+
| `REDUCED_MOTION_SHADOWED_EFFECT_ID` | A `config.effects` key is `ignore` / `cancel` / `collapse`, so `reducedMotionPolicy` can't name it. | `REDUCED_MOTION` |
|
|
247
|
+
| `REDUCED_MOTION_ANIMATION_END_SOURCE_MISMATCH` | An `animationEnd` source effect gets a different `reducedMotionPolicy` where it plays than from its registry entry, which is all the `animationEnd` trigger sees. | `REDUCED_MOTION` |
|
|
248
|
+
| `REDUCED_MOTION_COLLAPSE_CANCELS` (info) | A collapsed effect has no end state (infinite iterations, or `viewProgress` / `pointerMove`), so reduced motion cancels it. Not reported when no `reducedMotionPolicy` is set. | `REDUCED_MOTION` |
|
|
249
|
+
|
|
250
|
+
The instance's `reducedMotionPolicy` (an `Interact.setup()` / `Interact.create()` option) isn't part of the config, so the `REDUCED_MOTION_*` checks take it to be the default `'collapse'`.
|
|
242
251
|
|
|
243
252
|
---
|
|
244
253
|
|