@wix/interact 2.1.4 → 2.2.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/cjs/web.js.map +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/react.js +2 -2
- package/dist/es/web.js +15 -15
- package/dist/es/web.js.map +1 -1
- package/dist/index-C0nIxDnf.js +18 -0
- package/dist/index-C0nIxDnf.js.map +1 -0
- package/dist/{index-DHqlFmW8.mjs → index-CJl_iRUI.mjs} +495 -487
- package/dist/index-CJl_iRUI.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/core/Interact.d.ts +2 -2
- package/dist/types/core/Interact.d.ts.map +1 -1
- package/dist/types/core/InteractionController.d.ts +2 -2
- 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.map +1 -1
- package/dist/types/handlers/effectHandlers.d.ts +4 -4
- package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
- package/dist/types/handlers/eventTrigger.d.ts +2 -2
- package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
- package/dist/types/handlers/index.d.ts.map +1 -1
- package/dist/types/handlers/viewEnter.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/react/index.d.ts +1 -1
- package/dist/types/react/index.d.ts.map +1 -1
- package/dist/types/types/config.d.ts +47 -0
- package/dist/types/types/config.d.ts.map +1 -0
- package/dist/types/types/controller.d.ts +34 -0
- package/dist/types/types/controller.d.ts.map +1 -0
- package/dist/types/types/effects.d.ts +75 -0
- package/dist/types/types/effects.d.ts.map +1 -0
- package/dist/types/types/external.d.ts +6 -0
- package/dist/types/types/external.d.ts.map +1 -0
- package/dist/types/types/global.d.ts +11 -0
- package/dist/types/types/global.d.ts.map +1 -0
- package/dist/types/types/handlers.d.ts +41 -0
- package/dist/types/types/handlers.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +8 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/internal.d.ts +36 -0
- package/dist/types/types/internal.d.ts.map +1 -0
- package/dist/types/types/triggers.d.ts +28 -0
- package/dist/types/types/triggers.d.ts.map +1 -0
- package/dist/types/web/InteractElement.d.ts +2 -2
- package/dist/types/web/InteractElement.d.ts.map +1 -1
- package/dist/types/web/index.d.ts +1 -1
- package/dist/types/web/index.d.ts.map +1 -1
- package/docs/api/README.md +2 -3
- package/docs/api/functions.md +4 -4
- package/docs/api/interact-class.md +2 -3
- package/docs/api/interact-element.md +2 -2
- package/docs/api/interaction-controller.md +4 -4
- package/docs/api/types.md +38 -69
- package/docs/examples/README.md +1 -1
- package/docs/examples/click-interactions.md +0 -7
- package/docs/examples/entrance-animations.md +28 -27
- package/docs/examples/list-patterns.md +17 -16
- package/docs/guides/conditions-and-media-queries.md +2 -3
- package/docs/guides/configuration-structure.md +5 -7
- package/docs/guides/effects-and-animations.md +2 -4
- package/docs/guides/getting-started.md +0 -1
- package/docs/guides/lists-and-dynamic-content.md +10 -9
- package/docs/guides/sequences.md +3 -4
- package/docs/guides/state-management.md +0 -2
- package/docs/guides/understanding-triggers.md +9 -13
- package/package.json +2 -2
- package/rules/click.md +96 -560
- package/rules/full-lean.md +546 -359
- package/rules/hover.md +107 -530
- package/rules/integration.md +222 -261
- package/rules/pointermove.md +154 -1407
- package/rules/viewenter.md +128 -863
- package/rules/viewprogress.md +88 -322
- package/dist/index-DHqlFmW8.mjs.map +0 -1
- package/dist/index-DYEvpIGz.js +0 -18
- package/dist/index-DYEvpIGz.js.map +0 -1
- package/dist/types/types.d.ts +0 -256
- package/dist/types/types.d.ts.map +0 -1
- package/rules/MASTER-CLEANUP-PLAN.md +0 -286
- package/rules/scroll-list.md +0 -748
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Effect, EffectRef, StateEffect, TransitionProperty } from './effects';
|
|
2
|
+
import type { Condition, SequenceConfig, Interaction, InteractionTrigger } from './config';
|
|
3
|
+
export type InteractCache = {
|
|
4
|
+
effects: {
|
|
5
|
+
[effectId: string]: Effect;
|
|
6
|
+
};
|
|
7
|
+
sequences: {
|
|
8
|
+
[sequenceId: string]: SequenceConfig;
|
|
9
|
+
};
|
|
10
|
+
conditions: {
|
|
11
|
+
[conditionId: string]: Condition;
|
|
12
|
+
};
|
|
13
|
+
interactions: {
|
|
14
|
+
[path: string]: {
|
|
15
|
+
triggers: Interaction[];
|
|
16
|
+
effects: Record<string, (InteractionTrigger & {
|
|
17
|
+
effect: Effect | EffectRef;
|
|
18
|
+
})[]>;
|
|
19
|
+
sequences: Record<string, (InteractionTrigger & {
|
|
20
|
+
sequence: SequenceConfig;
|
|
21
|
+
})[]>;
|
|
22
|
+
interactionIds: Set<string>;
|
|
23
|
+
selectors: Set<string>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type CreateTransitionCSSParams = {
|
|
28
|
+
key: string;
|
|
29
|
+
effectId: string;
|
|
30
|
+
transition?: StateEffect['transition'];
|
|
31
|
+
properties?: TransitionProperty[];
|
|
32
|
+
childSelector?: string;
|
|
33
|
+
selectorCondition?: string;
|
|
34
|
+
useFirstChild?: boolean;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpF,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;IACF,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,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RangeOffset } from '@wix/motion';
|
|
2
|
+
export type { RangeOffset };
|
|
3
|
+
export type PointerMoveAxis = 'x' | 'y';
|
|
4
|
+
export type TriggerType = 'hover' | 'click' | 'viewEnter' | 'pageVisible' | 'animationEnd' | 'viewProgress' | 'pointerMove' | 'activate' | 'interest';
|
|
5
|
+
export type EventTriggerKind = 'toggle' | 'enterLeave';
|
|
6
|
+
export type EventTriggerConfigToggle = readonly string[] | string[];
|
|
7
|
+
export type EventTriggerConfigEnterLeave = {
|
|
8
|
+
enter?: readonly string[];
|
|
9
|
+
leave?: readonly string[];
|
|
10
|
+
};
|
|
11
|
+
export type EventTriggerConfig = string | EventTriggerConfigToggle | EventTriggerConfigEnterLeave;
|
|
12
|
+
export type EventTriggerParams = {
|
|
13
|
+
eventConfig: EventTriggerConfig;
|
|
14
|
+
};
|
|
15
|
+
export type ViewEnterParams = {
|
|
16
|
+
threshold?: number;
|
|
17
|
+
inset?: string;
|
|
18
|
+
useSafeViewEnter?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type PointerMoveParams = {
|
|
21
|
+
hitArea?: 'root' | 'self';
|
|
22
|
+
axis?: PointerMoveAxis;
|
|
23
|
+
};
|
|
24
|
+
export type AnimationEndParams = {
|
|
25
|
+
effectId: string;
|
|
26
|
+
};
|
|
27
|
+
export type TriggerParams = ViewEnterParams | PointerMoveParams | AnimationEndParams;
|
|
28
|
+
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../src/types/triggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,MAAM,MAAM,eAAe,GAAG,GAAG,GAAG,GAAG,CAAC;AAExC,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,OAAO,GACP,WAAW,GACX,aAAa,GACb,cAAc,GACd,cAAc,GACd,aAAa,GACb,UAAU,GACV,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,YAAY,CAAC;AACvD,MAAM,MAAM,wBAAwB,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;AACpE,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,wBAAwB,GAAG,4BAA4B,CAAC;AAElG,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,kBAAkB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,iBAAiB,GAAG,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IInteractionController,
|
|
1
|
+
import type { IInteractionController, StateAction } from '../types';
|
|
2
2
|
export declare const INTERACT_EFFECT_DATA_ATTR = "interactEffect";
|
|
3
3
|
export declare function getInteractElement(): {
|
|
4
4
|
new (): {
|
|
@@ -12,7 +12,7 @@ export declare function getInteractElement(): {
|
|
|
12
12
|
disconnect(options?: {
|
|
13
13
|
removeFromCache?: boolean;
|
|
14
14
|
}): void;
|
|
15
|
-
toggleEffect(effectId: string,
|
|
15
|
+
toggleEffect(effectId: string, stateAction: StateAction, item?: HTMLElement | null): void;
|
|
16
16
|
getActiveEffects(): string[];
|
|
17
17
|
accessKey: string;
|
|
18
18
|
readonly accessKeyLabel: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractElement.d.ts","sourceRoot":"","sources":["../../../src/web/InteractElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGpE,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,wBAAgB,kBAAkB;;oBAKlB,CAAC,gBAAgB,GAAG;YAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;SAAE,CAAC,GAAG,IAAI;oBACnD,sBAAsB;;;sBAiCpB,MAAM;6BAQC;YAAE,eAAe,CAAC,EAAE,OAAO,CAAA;SAAE;+BAI3B,MAAM,
|
|
1
|
+
{"version":3,"file":"InteractElement.d.ts","sourceRoot":"","sources":["../../../src/web/InteractElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGpE,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,wBAAgB,kBAAkB;;oBAKlB,CAAC,gBAAgB,GAAG;YAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;SAAE,CAAC,GAAG,IAAI;oBACnD,sBAAsB;;;sBAiCpB,MAAM;6BAQC;YAAE,eAAe,CAAC,EAAE,OAAO,CAAA;SAAE;+BAI3B,MAAM,eAAe,WAAW,SAAS,WAAW,GAAG,IAAI;4BA4B9D,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,cAAc,mBAAmB,CAAC"}
|
package/docs/api/README.md
CHANGED
|
@@ -54,7 +54,6 @@ Complete reference documentation for all public APIs in `@wix/interact`.
|
|
|
54
54
|
|
|
55
55
|
- [**TriggerType**](types.md#triggertype) - Union of all supported triggers
|
|
56
56
|
- [**ViewEnterParams**](types.md#viewenterparams) - Viewport entry configuration
|
|
57
|
-
- [**StateParams**](types.md#stateparams) - State transition parameters
|
|
58
57
|
- [**PointerMoveParams**](types.md#pointermoveparams) - Pointer movement configuration
|
|
59
58
|
- [**AnimationEndParams**](types.md#animationendparams) - Animation completion triggers
|
|
60
59
|
|
|
@@ -62,7 +61,7 @@ Complete reference documentation for all public APIs in `@wix/interact`.
|
|
|
62
61
|
|
|
63
62
|
- [**TimeEffect**](types.md#timeeffect) - Time-based animations with examples
|
|
64
63
|
- [**ScrubEffect**](types.md#scrubeffect) - Progress-based animations with named ranges
|
|
65
|
-
- [**
|
|
64
|
+
- [**StateEffect**](types.md#stateeffect) - CSS transition effects
|
|
66
65
|
- [**EffectRef**](types.md#effectref) - Effect reference by ID
|
|
67
66
|
|
|
68
67
|
### Advanced Types
|
|
@@ -126,7 +125,7 @@ InteractConfig
|
|
|
126
125
|
├── effects?: Record<string, Effect>
|
|
127
126
|
│ ├── TimeEffect (duration-based)
|
|
128
127
|
│ ├── ScrubEffect (progress-based)
|
|
129
|
-
│ └──
|
|
128
|
+
│ └── StateEffect (CSS transitions)
|
|
130
129
|
└── conditions?: Record<string, Condition>
|
|
131
130
|
├── Media queries
|
|
132
131
|
├── Container queries
|
package/docs/api/functions.md
CHANGED
|
@@ -198,7 +198,7 @@ console.log('Interactions removed for hero');
|
|
|
198
198
|
|
|
199
199
|
## `generate(config, useFirstChild?)`
|
|
200
200
|
|
|
201
|
-
Generates CSS styles needed to hide elements that have entrance animations with a `viewEnter` trigger and `
|
|
201
|
+
Generates CSS styles needed to hide elements that have entrance animations with a `viewEnter` trigger and the default (or explicit) `triggerType: 'once'` on effects. This prevents a flash of unstyled content (FOUC) where elements briefly appear before their entrance animation starts.
|
|
202
202
|
|
|
203
203
|
### Signature
|
|
204
204
|
|
|
@@ -208,7 +208,7 @@ function generate(config: InteractConfig, useFirstChild?: boolean): string;
|
|
|
208
208
|
|
|
209
209
|
### Parameters
|
|
210
210
|
|
|
211
|
-
**`config: InteractConfig`** - The interaction configuration; used to find `viewEnter
|
|
211
|
+
**`config: InteractConfig`** - The interaction configuration; used to find `viewEnter` interactions whose time effects use `triggerType: 'once'` (the default) and build selectors.
|
|
212
212
|
|
|
213
213
|
**`useFirstChild?: boolean`** - When `true`, targets the first child of each key (e.g. for `<interact-element>`). Default `false`.
|
|
214
214
|
|
|
@@ -221,7 +221,7 @@ function generate(config: InteractConfig, useFirstChild?: boolean): string;
|
|
|
221
221
|
The function generates CSS that:
|
|
222
222
|
|
|
223
223
|
1. **Respects reduced motion**: Wrapped in `@media (prefers-reduced-motion: no-preference)`.
|
|
224
|
-
2. **Targets elements by key**: Selectors use `[data-interact-key="..."]` for each interaction key that has a `viewEnter
|
|
224
|
+
2. **Targets elements by key**: Selectors use `[data-interact-key="..."]` for each interaction key that has a `viewEnter` entrance with `triggerType: 'once'` (including the default).
|
|
225
225
|
3. **Excludes completed animations**: Uses `:not([data-interact-enter])` so elements are shown after the animation runs.
|
|
226
226
|
|
|
227
227
|
**With `useFirstChild: false` (vanilla/React, element is the target)**:
|
|
@@ -264,7 +264,7 @@ const config = {
|
|
|
264
264
|
{
|
|
265
265
|
key: 'hero',
|
|
266
266
|
trigger: 'viewEnter',
|
|
267
|
-
params: {
|
|
267
|
+
params: { threshold: 0.2 },
|
|
268
268
|
effects: [
|
|
269
269
|
{
|
|
270
270
|
keyframeEffect: {
|
|
@@ -20,7 +20,7 @@ import { Interact } from '@wix/interact';
|
|
|
20
20
|
```typescript
|
|
21
21
|
class Interact {
|
|
22
22
|
// Static methods
|
|
23
|
-
static create(config: InteractConfig, options?: {
|
|
23
|
+
static create(config: InteractConfig, options?: { useCustomElement?: boolean }): Interact;
|
|
24
24
|
static getInstance(key: string): Interact | undefined;
|
|
25
25
|
static destroy(): void;
|
|
26
26
|
static setup(options: {
|
|
@@ -33,7 +33,7 @@ class Interact {
|
|
|
33
33
|
static getController(key: string | undefined): IInteractionController | undefined;
|
|
34
34
|
|
|
35
35
|
// Instance methods
|
|
36
|
-
init(config: InteractConfig, options?: {
|
|
36
|
+
init(config: InteractConfig, options?: { useCustomElement?: boolean }): void;
|
|
37
37
|
destroy(): void;
|
|
38
38
|
has(key: string): boolean;
|
|
39
39
|
get(key: string): InteractCache['interactions'][string] | undefined;
|
|
@@ -61,7 +61,6 @@ const config = {
|
|
|
61
61
|
interactions: [
|
|
62
62
|
{
|
|
63
63
|
trigger: 'viewEnter',
|
|
64
|
-
params: { type: 'once' },
|
|
65
64
|
key: 'hero',
|
|
66
65
|
effects: [{ effectId: 'fade-in' }],
|
|
67
66
|
},
|
|
@@ -148,14 +148,14 @@ const element = document.querySelector('interact-element') as IInteractElement;
|
|
|
148
148
|
element.disconnect();
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
### `toggleEffect(effectId,
|
|
151
|
+
### `toggleEffect(effectId, stateAction, item?)`
|
|
152
152
|
|
|
153
153
|
Toggles a CSS state effect on the element.
|
|
154
154
|
|
|
155
155
|
**Parameters:**
|
|
156
156
|
|
|
157
157
|
- `effectId: string` - The effect identifier
|
|
158
|
-
- `
|
|
158
|
+
- `stateAction: StateAction` - How to change the state (`'add' | 'remove' | 'toggle' | 'clear'`)
|
|
159
159
|
- `item?: HTMLElement | null` - Optional specific element for list items
|
|
160
160
|
|
|
161
161
|
**Example:**
|
|
@@ -36,7 +36,7 @@ interface IInteractionController {
|
|
|
36
36
|
update(): void;
|
|
37
37
|
toggleEffect(
|
|
38
38
|
effectId: string,
|
|
39
|
-
|
|
39
|
+
stateAction: StateAction,
|
|
40
40
|
item?: HTMLElement | null,
|
|
41
41
|
isLegacy?: boolean,
|
|
42
42
|
): void;
|
|
@@ -189,7 +189,7 @@ if (controller) {
|
|
|
189
189
|
- To reset all interaction state
|
|
190
190
|
- After modifying the element's structure
|
|
191
191
|
|
|
192
|
-
### `toggleEffect(effectId,
|
|
192
|
+
### `toggleEffect(effectId, stateAction, item?, isLegacy?)`
|
|
193
193
|
|
|
194
194
|
Toggles a CSS state effect on the element or a specific list item.
|
|
195
195
|
|
|
@@ -198,7 +198,7 @@ Toggles a CSS state effect on the element or a specific list item.
|
|
|
198
198
|
```typescript
|
|
199
199
|
toggleEffect(
|
|
200
200
|
effectId: string,
|
|
201
|
-
|
|
201
|
+
stateAction: StateAction,
|
|
202
202
|
item?: HTMLElement | null,
|
|
203
203
|
isLegacy?: boolean
|
|
204
204
|
): void
|
|
@@ -207,7 +207,7 @@ toggleEffect(
|
|
|
207
207
|
**Parameters:**
|
|
208
208
|
|
|
209
209
|
- `effectId: string` - The effect identifier
|
|
210
|
-
- `
|
|
210
|
+
- `stateAction` - How to change the state:
|
|
211
211
|
- `'add'` - Add the effect
|
|
212
212
|
- `'remove'` - Remove the effect
|
|
213
213
|
- `'toggle'` - Toggle the effect on/off
|
package/docs/api/types.md
CHANGED
|
@@ -172,7 +172,7 @@ interface IInteractionController {
|
|
|
172
172
|
update(): void;
|
|
173
173
|
toggleEffect(
|
|
174
174
|
effectId: string,
|
|
175
|
-
|
|
175
|
+
stateAction: StateAction,
|
|
176
176
|
item?: HTMLElement | null,
|
|
177
177
|
isLegacy?: boolean,
|
|
178
178
|
): void;
|
|
@@ -230,7 +230,7 @@ interface IInteractElement extends HTMLElement {
|
|
|
230
230
|
disconnectedCallback(): void;
|
|
231
231
|
connect(key?: string): void;
|
|
232
232
|
disconnect(options?: { removeFromCache?: boolean }): void;
|
|
233
|
-
toggleEffect(effectId: string,
|
|
233
|
+
toggleEffect(effectId: string, stateAction: StateAction, item?: HTMLElement | null): void;
|
|
234
234
|
getActiveEffects(): string[];
|
|
235
235
|
}
|
|
236
236
|
```
|
|
@@ -342,7 +342,6 @@ type TriggerType =
|
|
|
342
342
|
| 'interest'
|
|
343
343
|
| 'activate'
|
|
344
344
|
| 'viewEnter'
|
|
345
|
-
| 'pageVisible'
|
|
346
345
|
| 'animationEnd'
|
|
347
346
|
| 'viewProgress'
|
|
348
347
|
| 'pointerMove';
|
|
@@ -352,22 +351,18 @@ type TriggerType =
|
|
|
352
351
|
|
|
353
352
|
#### `ViewEnterParams`
|
|
354
353
|
|
|
355
|
-
Parameters for viewport entry triggers (`viewEnter`, `
|
|
354
|
+
Parameters for viewport entry triggers (`viewEnter`). Controls IntersectionObserver configuration only. Playback behavior (`'once'`, `'repeat'`, `'alternate'`, `'state'`) is configured via `triggerType` on the effect (see [TimeEffect](#timeeffect)) or on the sequence config (see [SequenceOptionsConfig](#sequenceoptionsconfig)).
|
|
356
355
|
|
|
357
356
|
```typescript
|
|
358
357
|
type ViewEnterParams = {
|
|
359
|
-
type?: ViewEnterType;
|
|
360
358
|
threshold?: number;
|
|
361
359
|
inset?: string;
|
|
362
360
|
useSafeViewEnter?: boolean;
|
|
363
361
|
};
|
|
364
|
-
|
|
365
|
-
type ViewEnterType = 'once' | 'repeat' | 'alternate' | 'state';
|
|
366
362
|
```
|
|
367
363
|
|
|
368
364
|
**Properties:**
|
|
369
365
|
|
|
370
|
-
- `type` - How the trigger behaves: `'once'` (default), `'repeat'`, `'alternate'`, `'state'` (play on enter, pause on exit)
|
|
371
366
|
- `threshold` - Percentage of element that must be visible (0-1)
|
|
372
367
|
- `inset` - CSS-style inset to shrink the root intersection area
|
|
373
368
|
- `useSafeViewEnter` - When true, handles elements taller than viewport
|
|
@@ -375,58 +370,16 @@ type ViewEnterType = 'once' | 'repeat' | 'alternate' | 'state';
|
|
|
375
370
|
**Examples:**
|
|
376
371
|
|
|
377
372
|
```typescript
|
|
378
|
-
// Trigger
|
|
379
|
-
const
|
|
380
|
-
type: 'once',
|
|
373
|
+
// Trigger when 50% visible
|
|
374
|
+
const params: ViewEnterParams = {
|
|
381
375
|
threshold: 0.5,
|
|
382
376
|
};
|
|
383
377
|
|
|
384
|
-
// Trigger
|
|
385
|
-
const
|
|
386
|
-
type: 'repeat',
|
|
378
|
+
// Trigger with margin
|
|
379
|
+
const paramsWithMargin: ViewEnterParams = {
|
|
387
380
|
threshold: 0.1,
|
|
388
381
|
inset: '100px',
|
|
389
382
|
};
|
|
390
|
-
|
|
391
|
-
// Alternate effects on enter/exit
|
|
392
|
-
const alternateParams: ViewEnterParams = {
|
|
393
|
-
type: 'alternate',
|
|
394
|
-
threshold: 0.3,
|
|
395
|
-
};
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
#### `StateParams`
|
|
399
|
-
|
|
400
|
-
Parameters for state-based triggers (`hover`, `click`, `interest`, `activate`).
|
|
401
|
-
|
|
402
|
-
```typescript
|
|
403
|
-
type StateParams = {
|
|
404
|
-
method: TransitionMethod;
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
type TransitionMethod = 'add' | 'remove' | 'toggle' | 'clear';
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
**Properties:**
|
|
411
|
-
|
|
412
|
-
- `method` - How to modify the element's state
|
|
413
|
-
- `'add'` - Add the effect state
|
|
414
|
-
- `'remove'` - Remove the effect state
|
|
415
|
-
- `'toggle'` - Toggle the effect state
|
|
416
|
-
- `'clear'` - Clear all effect states
|
|
417
|
-
|
|
418
|
-
**Examples:**
|
|
419
|
-
|
|
420
|
-
```typescript
|
|
421
|
-
// Toggle effect on click
|
|
422
|
-
const toggleClick: StateParams = {
|
|
423
|
-
method: 'toggle',
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
// Add effect on hover enter, remove on hover exit
|
|
427
|
-
const hoverState: StateParams = {
|
|
428
|
-
method: 'add', // hover exit automatically uses 'remove'
|
|
429
|
-
};
|
|
430
383
|
```
|
|
431
384
|
|
|
432
385
|
#### `PointerMoveParams`
|
|
@@ -485,7 +438,7 @@ const chainedAnimation: AnimationEndParams = {
|
|
|
485
438
|
Union type of all effect types.
|
|
486
439
|
|
|
487
440
|
```typescript
|
|
488
|
-
type Effect = (TimeEffect | ScrubEffect |
|
|
441
|
+
type Effect = (TimeEffect | ScrubEffect | StateEffect) & {
|
|
489
442
|
conditions?: string[];
|
|
490
443
|
};
|
|
491
444
|
```
|
|
@@ -507,6 +460,7 @@ type TimeEffect = {
|
|
|
507
460
|
reversed?: boolean;
|
|
508
461
|
delay?: number;
|
|
509
462
|
effectId?: string;
|
|
463
|
+
triggerType?: TimeAnimationTriggerType;
|
|
510
464
|
} & EffectProperty;
|
|
511
465
|
|
|
512
466
|
type Fill = 'none' | 'forwards' | 'backwards' | 'both';
|
|
@@ -524,6 +478,11 @@ type Fill = 'none' | 'forwards' | 'backwards' | 'both';
|
|
|
524
478
|
- `fill` - How to apply styles before/after animation
|
|
525
479
|
- `reversed` - Whether to play animation in reverse
|
|
526
480
|
- `delay` - Delay before animation starts in milliseconds
|
|
481
|
+
- `triggerType` - Controls play behavior for event triggers (`hover`, `click`, `activate`, `interest`, `viewEnter`):
|
|
482
|
+
- `'alternate'` (default for hover/click) - Hover & viewEnter: play on enter, reverse on leave. Click: alternate play/reverse on successive clicks.
|
|
483
|
+
- `'repeat'` - Restart from progress 0 on each event; on hover leave the animation is canceled; on viewEnter full exit, pause and reset.
|
|
484
|
+
- `'once'` (default for viewEnter) - Play once and remove the listener (hover & viewEnter attach only the enter listener; no leave).
|
|
485
|
+
- `'state'` - Hover & viewEnter: play on enter if idle/paused, pause on leave if running. Click: toggle play/pause on successive clicks until finished.
|
|
527
486
|
|
|
528
487
|
**Examples:**
|
|
529
488
|
|
|
@@ -623,20 +582,23 @@ const progressFade: ScrubEffect = {
|
|
|
623
582
|
};
|
|
624
583
|
```
|
|
625
584
|
|
|
626
|
-
### `
|
|
585
|
+
### `StateEffect`
|
|
627
586
|
|
|
628
587
|
CSS transition-based effects for style property changes.
|
|
629
588
|
|
|
630
589
|
```typescript
|
|
631
|
-
type
|
|
590
|
+
type StateEffect = {
|
|
632
591
|
key?: string;
|
|
633
592
|
effectId?: string;
|
|
593
|
+
stateAction?: StateAction;
|
|
634
594
|
transition?: TransitionOptions & {
|
|
635
595
|
styleProperties: StyleProperty[];
|
|
636
596
|
};
|
|
637
597
|
transitionProperties?: TransitionProperty[];
|
|
638
598
|
};
|
|
639
599
|
|
|
600
|
+
type StateAction = 'add' | 'remove' | 'toggle' | 'clear';
|
|
601
|
+
|
|
640
602
|
type TransitionOptions = {
|
|
641
603
|
duration?: number;
|
|
642
604
|
delay?: number;
|
|
@@ -651,11 +613,19 @@ type StyleProperty = {
|
|
|
651
613
|
type TransitionProperty = StyleProperty & TransitionOptions;
|
|
652
614
|
```
|
|
653
615
|
|
|
616
|
+
**Properties:**
|
|
617
|
+
|
|
618
|
+
- `stateAction` - How to modify the element's CSS state on event triggers (`hover`, `click`, `activate`, `interest`):
|
|
619
|
+
- `'toggle'` (default) - Hover: adds on enter, removes on leave. Click: toggles on each click.
|
|
620
|
+
- `'add'` - Add the effect state; hover leave will NOT auto-remove.
|
|
621
|
+
- `'remove'` - Remove the effect state.
|
|
622
|
+
- `'clear'` - Clear all effect states for the element (or list item when list context is used).
|
|
623
|
+
|
|
654
624
|
**Examples:**
|
|
655
625
|
|
|
656
626
|
```typescript
|
|
657
627
|
// Simple color transition
|
|
658
|
-
const colorTransition:
|
|
628
|
+
const colorTransition: StateEffect = {
|
|
659
629
|
transition: {
|
|
660
630
|
duration: 300,
|
|
661
631
|
easing: 'ease-out',
|
|
@@ -667,7 +637,7 @@ const colorTransition: TransitionEffect = {
|
|
|
667
637
|
};
|
|
668
638
|
|
|
669
639
|
// Individual property transitions
|
|
670
|
-
const complexTransition:
|
|
640
|
+
const complexTransition: StateEffect = {
|
|
671
641
|
transitionProperties: [
|
|
672
642
|
{
|
|
673
643
|
name: 'transform',
|
|
@@ -792,6 +762,7 @@ type SequenceOptionsConfig = {
|
|
|
792
762
|
offsetEasing?: string | ((p: number) => number);
|
|
793
763
|
sequenceId?: string;
|
|
794
764
|
conditions?: string[];
|
|
765
|
+
triggerType?: TimeAnimationTriggerType;
|
|
795
766
|
};
|
|
796
767
|
```
|
|
797
768
|
|
|
@@ -802,6 +773,7 @@ type SequenceOptionsConfig = {
|
|
|
802
773
|
- `offsetEasing` - Easing function or named string for offset distribution (`'linear'`, `'quadIn'`, `'sineOut'`, etc.). Default: `linear`.
|
|
803
774
|
- `sequenceId` - Optional ID for referencing a reusable sequence from `InteractConfig.sequences`.
|
|
804
775
|
- `conditions` - Optional array of condition IDs. When set, the sequence is only active when all conditions match.
|
|
776
|
+
- `triggerType` - Controls play behavior for event trigger sequences (`hover`, `click`, `activate`, `interest`, `viewEnter`). Same values as `TimeEffect.triggerType`: `'once'` (default for viewEnter), `'alternate'` (default for hover/click), `'repeat'`, `'state'`.
|
|
805
777
|
|
|
806
778
|
### `SequenceConfig`
|
|
807
779
|
|
|
@@ -944,10 +916,10 @@ Map of trigger types to their parameter types.
|
|
|
944
916
|
|
|
945
917
|
```typescript
|
|
946
918
|
type InteractionParamsTypes = {
|
|
947
|
-
hover:
|
|
948
|
-
click:
|
|
949
|
-
interest:
|
|
950
|
-
activate:
|
|
919
|
+
hover: Record<string, never>;
|
|
920
|
+
click: Record<string, never>;
|
|
921
|
+
interest: Record<string, never>;
|
|
922
|
+
activate: Record<string, never>;
|
|
951
923
|
viewEnter: ViewEnterParams;
|
|
952
924
|
pageVisible: ViewEnterParams;
|
|
953
925
|
animationEnd: AnimationEndParams;
|
|
@@ -956,17 +928,14 @@ type InteractionParamsTypes = {
|
|
|
956
928
|
};
|
|
957
929
|
```
|
|
958
930
|
|
|
931
|
+
> **Note:** `hover`, `click`, `interest`, `activate`, and `viewEnter` triggers no longer use params for playback behavior. Animation behavior (`triggerType`) is now configured on `TimeEffect` (or `SequenceOptionsConfig` for sequences), and state behavior (`stateAction`) is now configured on `StateEffect`. `viewEnter`/`pageVisible` params only contain observer configuration (`threshold`, `inset`, `useSafeViewEnter`).
|
|
932
|
+
|
|
959
933
|
### `TriggerParams`
|
|
960
934
|
|
|
961
935
|
Union type of all trigger parameter types.
|
|
962
936
|
|
|
963
937
|
```typescript
|
|
964
|
-
type TriggerParams =
|
|
965
|
-
| StateParams
|
|
966
|
-
| PointerTriggerParams
|
|
967
|
-
| ViewEnterParams
|
|
968
|
-
| PointerMoveParams
|
|
969
|
-
| AnimationEndParams;
|
|
938
|
+
type TriggerParams = ViewEnterParams | PointerMoveParams | AnimationEndParams;
|
|
970
939
|
```
|
|
971
940
|
|
|
972
941
|
## See Also
|
package/docs/examples/README.md
CHANGED
|
@@ -172,7 +172,6 @@ Toggle between two states.
|
|
|
172
172
|
{
|
|
173
173
|
key: 'toggle-switch',
|
|
174
174
|
trigger: 'click',
|
|
175
|
-
params: { method: 'toggle' },
|
|
176
175
|
effects: [{
|
|
177
176
|
key: 'toggle-switch',
|
|
178
177
|
transition: {
|
|
@@ -231,7 +230,6 @@ Custom checkbox with animation.
|
|
|
231
230
|
{
|
|
232
231
|
key: 'checkbox',
|
|
233
232
|
trigger: 'click',
|
|
234
|
-
params: { method: 'toggle' },
|
|
235
233
|
effects: [{
|
|
236
234
|
key: 'checkbox',
|
|
237
235
|
selector: '.checkmark',
|
|
@@ -271,7 +269,6 @@ Heart animation for like button.
|
|
|
271
269
|
{
|
|
272
270
|
key: 'like-button',
|
|
273
271
|
trigger: 'click',
|
|
274
|
-
params: { method: 'toggle' },
|
|
275
272
|
effects: [{
|
|
276
273
|
key: 'like-button',
|
|
277
274
|
selector: '.heart-icon',
|
|
@@ -301,7 +298,6 @@ Click to reveal hidden content.
|
|
|
301
298
|
key: 'accordion-trigger',
|
|
302
299
|
selector: '.accordion-header',
|
|
303
300
|
trigger: 'click',
|
|
304
|
-
params: { method: 'toggle' },
|
|
305
301
|
effects: [{
|
|
306
302
|
key: 'accordion-trigger',
|
|
307
303
|
selector: '.accordion-content',
|
|
@@ -350,7 +346,6 @@ Expand text content on click.
|
|
|
350
346
|
key: 'read-more',
|
|
351
347
|
selector: '.read-more-btn',
|
|
352
348
|
trigger: 'click',
|
|
353
|
-
params: { method: 'toggle' },
|
|
354
349
|
effects: [
|
|
355
350
|
// Expand content
|
|
356
351
|
{
|
|
@@ -705,7 +700,6 @@ Toggle mobile navigation menu.
|
|
|
705
700
|
{
|
|
706
701
|
key: 'menu-toggle',
|
|
707
702
|
trigger: 'click',
|
|
708
|
-
params: { method: 'toggle' },
|
|
709
703
|
effects: [
|
|
710
704
|
// Hamburger icon animation
|
|
711
705
|
{
|
|
@@ -760,7 +754,6 @@ Click to toggle dropdown.
|
|
|
760
754
|
{
|
|
761
755
|
key: 'dropdown-trigger',
|
|
762
756
|
trigger: 'click',
|
|
763
|
-
params: { method: 'toggle' },
|
|
764
757
|
effects: [
|
|
765
758
|
{
|
|
766
759
|
key: 'dropdown-trigger',
|