@wix/interact 2.0.0-rc.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,15 +8,15 @@ The `@wix/interact` package exports standalone functions for managing interactio
8
8
  import { add, remove, generate } from '@wix/interact';
9
9
  ```
10
10
 
11
- > **Note**: The `add` and `remove` functions are available from both `@wix/interact/web` and `@wix/interact/react` entry points. The `generate` function is only available from the main `@wix/interact` entry point.
11
+ > **Note**: `add`, `remove`, and `generate` are available from all entry points: `@wix/interact`, `@wix/interact/web`, and `@wix/interact/react`.
12
12
 
13
13
  ## Functions Overview
14
14
 
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 CSS for hiding elements with entrance animations | `config` | `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 CSS for hiding elements with entrance animations | `config`, `useFirstChild?` | `string` |
20
20
 
21
21
  ---
22
22
 
@@ -196,40 +196,39 @@ console.log('Interactions removed for hero');
196
196
 
197
197
  ---
198
198
 
199
- ## `generate(config)`
199
+ ## `generate(config, useFirstChild?)`
200
200
 
201
- Generates CSS styles needed to hide elements that have entrance animations with a `viewEnter` trigger. This prevents a flash of unstyled content (FOUC) where elements briefly appear before their entrance animation starts.
201
+ Generates CSS styles needed to hide elements that have entrance animations with a `viewEnter` trigger and `type: 'once'`. This prevents a flash of unstyled content (FOUC) where elements briefly appear before their entrance animation starts.
202
202
 
203
203
  ### Signature
204
204
 
205
205
  ```typescript
206
- function generate(config: InteractConfig): string;
206
+ function generate(config: InteractConfig, useFirstChild?: boolean): string;
207
207
  ```
208
208
 
209
209
  ### Parameters
210
210
 
211
- **`config: InteractConfig`**
211
+ **`config: InteractConfig`** - The interaction configuration; used to find `viewEnter`/`once` interactions and build selectors.
212
212
 
213
- - The interaction configuration object
214
- - Used to determine which elements need initial hiding styles
213
+ **`useFirstChild?: boolean`** - When `true`, targets the first child of each key (e.g. for `<interact-element>`). Default `false`.
215
214
 
216
215
  ### Returns
217
216
 
218
- **`string`** - A CSS string that can be injected into a `<style>` tag or stylesheet
217
+ **`string`** - A CSS string to inject into a `<style>` tag or stylesheet.
219
218
 
220
219
  ### Generated CSS
221
220
 
222
221
  The function generates CSS that:
223
222
 
224
- 1. **Respects reduced motion preferences**: Wrapped in `@media (prefers-reduced-motion: no-preference)` to ensure accessibility
225
- 2. **Targets first child of elements with `data-interact-initial="true"`**: Only affects elements explicitly marked for entrance animations
226
- 3. **Excludes completed animations**: Uses `:not([data-interact-enter="done"])` to show elements after their animation completes
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`/`once` entrance.
225
+ 3. **Excludes completed animations**: Uses `:not([data-interact-enter])` so elements are shown after the animation runs.
227
226
 
228
- **For the `web` integration (with custom elements)**:
227
+ **With `useFirstChild: false` (vanilla/React, element is the target)**:
229
228
 
230
229
  ```css
231
230
  @media (prefers-reduced-motion: no-preference) {
232
- [data-interact-initial='true'] > :first-child:not([data-interact-enter='done']) {
231
+ [data-interact-key='hero']:not([data-interact-enter]) {
233
232
  visibility: hidden;
234
233
  transform: none;
235
234
  translate: none;
@@ -239,11 +238,11 @@ The function generates CSS that:
239
238
  }
240
239
  ```
241
240
 
242
- **For other integrations (without custom elements)**:
241
+ **With `useFirstChild: true` (e.g. custom elements, first child is the target)**:
243
242
 
244
243
  ```css
245
244
  @media (prefers-reduced-motion: no-preference) {
246
- [data-interact-initial='true']:not([data-interact-enter='done']) {
245
+ [data-interact-key='hero'] > :first-child:not([data-interact-enter]) {
247
246
  visibility: hidden;
248
247
  transform: none;
249
248
  translate: none;
@@ -283,8 +282,8 @@ const config = {
283
282
  effects: {},
284
283
  };
285
284
 
286
- // Generate the CSS
287
- const css = generate(config);
285
+ // Generate the CSS (pass true when using custom elements so first child is targeted)
286
+ const css = generate(config, false);
288
287
 
289
288
  // Inject into page
290
289
  const styleElement = document.createElement('style');
@@ -328,21 +327,7 @@ const html = `
328
327
 
329
328
  ### HTML Setup
330
329
 
331
- For the generated CSS to work, the `<interact-element>` must have the `data-interact-initial="true"` attribute:
332
-
333
- ```html
334
- <interact-element data-interact-key="hero" data-interact-initial="true">
335
- <!-- First child will be hidden until viewEnter animation completes -->
336
- <section class="hero">
337
- <h1>Welcome</h1>
338
- </section>
339
- </interact-element>
340
-
341
- <!-- Without the attribute, element is visible immediately -->
342
- <interact-element data-interact-key="footer">
343
- <footer>Footer content</footer>
344
- </interact-element>
345
- ```
330
+ Elements must have `data-interact-key` matching the interaction key in your config. When using `<interact-element>`, use `generate(config, true)` so the first child is targeted. With the React `Interaction` component, use `initial={true}` to set `data-interact-initial="true"` for FOUC prevention; the generated CSS still selects by `data-interact-key`.
346
331
 
347
332
  ---
348
333
 
@@ -5,7 +5,7 @@ The `Interact` class is the main entry point for managing interactions in your a
5
5
  ## Import
6
6
 
7
7
  ```typescript
8
- // Web entry point with automatic custom-eleemnt registration
8
+ // Web entry point with automatic custom-element registration
9
9
  import { Interact } from '@wix/interact/web';
10
10
 
11
11
  // React entry point
@@ -20,19 +20,23 @@ import { Interact } from '@wix/interact';
20
20
  ```typescript
21
21
  class Interact {
22
22
  // Static methods
23
- static create(config: InteractConfig): Interact
24
- static getInstance(key: string): Interact | undefined
25
- static destroy(): void
26
- static setup(options: { forceReducedMotion?: boolean, ... }): void
27
- static registerEffects(effects: Record<string, NamedEffect>): void
28
- static getController(key: string): IInteractController | undefined
29
-
23
+ static create(config: InteractConfig, options?: { useCutsomElement?: boolean }): Interact;
24
+ static getInstance(key: string): Interact | undefined;
25
+ static destroy(): void;
26
+ static setup(options: {
27
+ scrollOptionsGetter?: () => Partial<scrollConfig>;
28
+ pointerOptionsGetter?: () => Partial<PointerConfig>;
29
+ viewEnter?: Partial<ViewEnterParams>;
30
+ allowA11yTriggers?: boolean;
31
+ }): void;
32
+ static registerEffects(effects: Record<string, NamedEffect>): void;
33
+ static getController(key: string | undefined): IInteractionController | undefined;
30
34
 
31
35
  // Instance methods
32
- init(config: InteractConfig): void
33
- destroy(): void
34
- has(key: string): boolean
35
- get(key: string): CachedInteractionData | undefined
36
+ init(config: InteractConfig, options?: { useCutsomElement?: boolean }): void;
37
+ destroy(): void;
38
+ has(key: string): boolean;
39
+ get(key: string): InteractCache['interactions'][string] | undefined;
36
40
  }
37
41
  ```
38
42
 
@@ -125,22 +129,29 @@ Configures global settings for the Interact system.
125
129
 
126
130
  **Parameters:**
127
131
 
128
- - `options: { forceReducedMotion?: boolean, viewEnter?: object, viewProgress?: object, pointerMove?: object, allowA11yTriggers?: boolean}`
132
+ - `options.scrollOptionsGetter` - Optional callback returning default partial scroll config for `viewProgress` trigger
133
+ - `options.pointerOptionsGetter` - Optional callback returning default partial pointer config for `pointerMove` trigger
134
+ - `options.viewEnter` - Optional default partial `ViewEnterParams` (e.g. `threshold`, `inset`, `useSafeViewEnter`)
135
+ - `options.allowA11yTriggers` - When `true`, `click` and `hover` triggers also respond to keyboard (Enter/Space) and focus
136
+
137
+ To force reduced motion globally, set `Interact.forceReducedMotion = true` (static property, not via `setup`).
129
138
 
130
139
  **Example:**
131
140
 
132
141
  ```typescript
133
- // Force reduced motion globally
142
+ // Configure viewEnter defaults
134
143
  Interact.setup({
135
- forceReducedMotion: true,
144
+ viewEnter: { threshold: 0.5 },
136
145
  });
137
146
 
138
- // Configure trigger-specific options
147
+ // Provide scroll/pointer options via getters
139
148
  Interact.setup({
140
- viewEnter: { threshold: 0.5 },
141
- viewProgress: {
142
- /* scroll options */
143
- },
149
+ scrollOptionsGetter: () => ({
150
+ /* scroll config */
151
+ }),
152
+ pointerOptionsGetter: () => ({
153
+ /* pointer config */
154
+ }),
144
155
  });
145
156
 
146
157
  // Enable accessibility for click and hover triggers
@@ -25,16 +25,14 @@ const controller = Interact.getController('my-element');
25
25
 
26
26
  ```typescript
27
27
  interface IInteractionController {
28
- // Properties
29
28
  element: HTMLElement;
30
29
  key: string | undefined;
31
30
  connected: boolean;
32
31
  sheet: CSSStyleSheet | null;
33
- _observers: WeakMap<HTMLElement, MutationObserver>;
32
+ useFirstChild: boolean;
34
33
 
35
- // Methods
36
34
  connect(key?: string): void;
37
- disconnect(): void;
35
+ disconnect(options?: { removeFromCache?: boolean }): void;
38
36
  update(): void;
39
37
  toggleEffect(
40
38
  effectId: string,
@@ -45,7 +43,6 @@ interface IInteractionController {
45
43
  getActiveEffects(): string[];
46
44
  renderStyle(cssRules: string[]): void;
47
45
  watchChildList(listContainer: string): void;
48
- _childListChangeHandler(listContainer: string, entries: MutationRecord[]): void;
49
46
  }
50
47
  ```
51
48
 
@@ -106,9 +103,9 @@ if (controller?.sheet) {
106
103
  }
107
104
  ```
108
105
 
109
- ### `_observers: WeakMap<HTMLElement, MutationObserver>`
106
+ ### `useFirstChild: boolean`
110
107
 
111
- Internal storage for mutation observers watching list containers.
108
+ When `true`, the interaction target is the first child (e.g. with `<interact-element>`). Set via constructor options.
112
109
 
113
110
  ## Methods
114
111
 
@@ -143,32 +140,28 @@ if (controller && !controller.connected) {
143
140
  4. Calls internal `add()` function to set up interactions
144
141
  5. Sets `connected = true` on success
145
142
 
146
- ### `disconnect()`
143
+ ### `disconnect(options?)`
147
144
 
148
- Disconnects the controller from the interaction system, cleaning up all resources.
145
+ Disconnects the controller and cleans up resources.
149
146
 
150
147
  **Signature:**
151
148
 
152
149
  ```typescript
153
- disconnect(): void
150
+ disconnect(options?: { removeFromCache?: boolean }): void
154
151
  ```
155
152
 
153
+ **Parameters:** `options.removeFromCache` - When `true`, removes the controller from `Interact.controllerCache` (e.g. when calling `remove(key)`).
154
+
156
155
  **Example:**
157
156
 
158
157
  ```typescript
159
158
  const controller = Interact.getController('my-element');
160
159
  if (controller?.connected) {
161
- controller.disconnect();
162
- console.log('Controller disconnected');
160
+ controller.disconnect({ removeFromCache: true });
163
161
  }
164
162
  ```
165
163
 
166
- **Behavior:**
167
-
168
- 1. Calls internal `remove()` to clean up interactions
169
- 2. Removes adopted stylesheet from document
170
- 3. Clears all mutation observers
171
- 4. Sets `connected = false`
164
+ **Behavior:** Calls internal `remove()`, removes adopted stylesheet, clears observers, sets `connected = false`.
172
165
 
173
166
  ### `update()`
174
167
 
@@ -351,16 +344,6 @@ if (controller) {
351
344
  4. Automatically calls `addListItems` for added nodes
352
345
  5. Automatically calls `removeListItems` for removed nodes
353
346
 
354
- ### `_childListChangeHandler(listContainer, entries)`
355
-
356
- Internal handler for mutation observer callbacks. You typically don't call this directly.
357
-
358
- **Signature:**
359
-
360
- ```typescript
361
- _childListChangeHandler(listContainer: string, entries: MutationRecord[]): void
362
- ```
363
-
364
347
  ## Usage Patterns
365
348
 
366
349
  ### Accessing Controllers
@@ -377,34 +360,15 @@ Interact.controllerCache.forEach((controller, key) => {
377
360
  });
378
361
  ```
379
362
 
380
- ### Programmatic State Management
363
+ ### State and lists
381
364
 
382
365
  ```typescript
383
- const controller = Interact.getController('accordion');
384
- if (controller) {
385
- // Check current state
386
- const isExpanded = controller.getActiveEffects().includes('expanded');
387
-
388
- // Toggle based on current state
389
- controller.toggleEffect('expanded', isExpanded ? 'remove' : 'add');
390
- }
391
- ```
366
+ // Toggle effect by current state
367
+ const c = Interact.getController('accordion');
368
+ c?.toggleEffect('expanded', c.getActiveEffects().includes('expanded') ? 'remove' : 'add');
392
369
 
393
- ### Dynamic List Management
394
-
395
- ```typescript
396
- const controller = Interact.getController('todo-list');
397
- if (controller) {
398
- // Watch for list changes
399
- controller.watchChildList('.todo-items');
400
-
401
- // Add new item - interactions apply automatically
402
- const todoItems = controller.element.querySelector('.todo-items');
403
- const newTodo = document.createElement('div');
404
- newTodo.className = 'todo-item';
405
- newTodo.textContent = 'New task';
406
- todoItems?.appendChild(newTodo);
407
- }
370
+ // Watch list container; new children get interactions automatically
371
+ Interact.getController('list-key')?.watchChildList('.items');
408
372
  ```
409
373
 
410
374
  ### Refreshing Interactions
@@ -449,7 +413,7 @@ const controller = Interact.getController('my-element');
449
413
  // Safe operations - won't throw
450
414
  controller?.toggleEffect('effect', 'add');
451
415
  controller?.connect(); // Safe if already connected
452
- controller?.disconnect(); // Safe if already disconnected
416
+ controller?.disconnect({}); // Safe if already disconnected
453
417
 
454
418
  // Check connection status
455
419
  if (!controller?.connected) {
package/docs/api/types.md CHANGED
@@ -124,7 +124,7 @@ type Interaction = {
124
124
 
125
125
  - `key` - Unique identifier for the custom element that triggers the interaction
126
126
  - `trigger` - Type of trigger event
127
- - `selector` - Optional CSS selector to target an element within the custom element or within each list item if combined with `listContainer`
127
+ - `selector` - Optional CSS selector to target elements. When `listContainer` is also specified, uses `querySelectorAll` within the container to find matching elements as list items. Without `listContainer`, uses `querySelectorAll` within the root element. For dynamically added list items, uses `querySelector` within each item.
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
@@ -161,16 +161,14 @@ Interface for the controller that manages interactions on an element. This is th
161
161
 
162
162
  ```typescript
163
163
  interface IInteractionController {
164
- // Properties
165
164
  element: HTMLElement;
166
165
  key: string | undefined;
167
166
  connected: boolean;
168
167
  sheet: CSSStyleSheet | null;
169
- _observers: WeakMap<HTMLElement, MutationObserver>;
168
+ useFirstChild: boolean;
170
169
 
171
- // Methods
172
170
  connect(key?: string): void;
173
- disconnect(): void;
171
+ disconnect(options?: { removeFromCache?: boolean }): void;
174
172
  update(): void;
175
173
  toggleEffect(
176
174
  effectId: string,
@@ -181,7 +179,6 @@ interface IInteractionController {
181
179
  getActiveEffects(): string[];
182
180
  renderStyle(cssRules: string[]): void;
183
181
  watchChildList(listContainer: string): void;
184
- _childListChangeHandler(listContainer: string, entries: MutationRecord[]): void;
185
182
  }
186
183
  ```
187
184
 
@@ -189,14 +186,14 @@ interface IInteractionController {
189
186
 
190
187
  - `element` - The DOM element this controller manages
191
188
  - `key` - The unique identifier for this element's interactions
192
- - `connected` - Whether the controller is currently connected to the interaction system
189
+ - `connected` - Whether the controller is currently connected
193
190
  - `sheet` - The adopted stylesheet for dynamic CSS rules
194
- - `_observers` - Internal storage for mutation observers
191
+ - `useFirstChild` - When true, interaction target is the first child (e.g. custom elements)
195
192
 
196
193
  **Methods:**
197
194
 
198
195
  - `connect(key?)` - Connects the controller to the interaction system
199
- - `disconnect()` - Disconnects and cleans up all resources
196
+ - `disconnect(options?)` - Disconnects and cleans up; `removeFromCache: true` removes from `Interact.controllerCache`
200
197
  - `update()` - Disconnects and reconnects (refreshes interactions)
201
198
  - `toggleEffect()` - Toggles a CSS state effect on the element
202
199
  - `getActiveEffects()` - Returns array of currently active effect IDs
@@ -232,7 +229,7 @@ interface IInteractElement extends HTMLElement {
232
229
  connectedCallback(): void;
233
230
  disconnectedCallback(): void;
234
231
  connect(key?: string): void;
235
- disconnect(): void;
232
+ disconnect(options?: { removeFromCache?: boolean }): void;
236
233
  toggleEffect(effectId: string, method: StateParams['method'], item?: HTMLElement | null): void;
237
234
  getActiveEffects(): string[];
238
235
  }
@@ -362,19 +359,18 @@ type ViewEnterParams = {
362
359
  type?: ViewEnterType;
363
360
  threshold?: number;
364
361
  inset?: string;
362
+ useSafeViewEnter?: boolean;
365
363
  };
366
364
 
367
- type ViewEnterType = 'once' | 'repeat' | 'alternate';
365
+ type ViewEnterType = 'once' | 'repeat' | 'alternate' | 'state';
368
366
  ```
369
367
 
370
368
  **Properties:**
371
369
 
372
- - `type` - How the trigger behaves on repeated intersections
373
- - `'once'` - Trigger only the first time (default)
374
- - `'repeat'` - Trigger every time element enters viewport
375
- - `'alternate'` - Alternate between enter/exit effects
370
+ - `type` - How the trigger behaves: `'once'` (default), `'repeat'`, `'alternate'`, `'state'` (play on enter, pause on exit)
376
371
  - `threshold` - Percentage of element that must be visible (0-1)
377
372
  - `inset` - CSS-style inset to shrink the root intersection area
373
+ - `useSafeViewEnter` - When true, handles elements taller than viewport
378
374
 
379
375
  **Examples:**
380
376
 
@@ -438,22 +434,25 @@ const hoverState: StateParams = {
438
434
  Parameters for pointer/mouse movement triggers.
439
435
 
440
436
  ```typescript
437
+ type PointerMoveAxis = 'x' | 'y';
438
+
441
439
  type PointerMoveParams = {
442
440
  hitArea?: 'root' | 'self';
441
+ axis?: PointerMoveAxis;
443
442
  };
444
443
  ```
445
444
 
446
445
  **Properties:**
447
446
 
448
- - `hitArea` - Defines the area that responds to pointer movement
449
- - `'self'` - Only the source element (default)
450
- - `'root'` - The entire viewport/root container
447
+ - `hitArea` - `'self'` (default) or `'root'` (viewport)
448
+ - `axis` - `'x'` or `'y'` (default `'y'`) for scrub direction
451
449
 
452
450
  **Example:**
453
451
 
454
452
  ```typescript
455
453
  const pointerParams: PointerMoveParams = {
456
- hitArea: 'root', // Track mouse across entire page
454
+ hitArea: 'self',
455
+ axis: 'y',
457
456
  };
458
457
  ```
459
458
 
@@ -516,7 +515,7 @@ type Fill = 'none' | 'forwards' | 'backwards' | 'both';
516
515
  **Properties:**
517
516
 
518
517
  - `key` - unique identifier for targeting a custom element (optional, defaults to source key from the `Interaction`)
519
- - `selector` - CSS selector for targeting an element inside the custom element or each list item if combined with `listContainer` (optional, defaults to `firstElementChild`)
518
+ - `selector` - CSS selector for targeting elements inside the custom element (uses `querySelectorAll`) or each list item if combined with `listContainer` (optional, defaults to `firstElementChild`)
520
519
  - `listContainer` - CSS selector for list container when targeting list items (optional)
521
520
  - `duration` - Animation duration in milliseconds (required)
522
521
  - `easing` - Easing function name or custom cubic-bezier
@@ -750,8 +749,8 @@ type EffectProperty =
750
749
  **Types:**
751
750
 
752
751
  - `keyframeEffect` - Raw keyframe animation definition
753
- - `namedEffect` - Pre-built animation from `@wix/motion`
754
- - `customEffect` - Custom animation function
752
+ - `namedEffect` - Pre-built animations from `@wix/motion-presets`
753
+ - `customEffect` - Function `(element: Element, progress: number) => void` for custom scrub/behavior
755
754
 
756
755
  **Examples:**
757
756
 
@@ -769,18 +768,13 @@ const keyframeEffect = {
769
768
 
770
769
  // Named effect
771
770
  const namedEffect = {
772
- namedEffect: {
773
- type: 'SlideIn',
774
- }, // Pre-built animation
771
+ namedEffect: { type: 'SlideIn' },
775
772
  };
776
773
 
777
- // Custom effect
774
+ // Custom effect (signature: element, progress)
778
775
  const customEffect = {
779
- customEffect: (element: HTMLElement) => {
780
- // Custom animation logic
781
- return element.animate([{ transform: 'rotate(0deg)' }, { transform: 'rotate(360deg)' }], {
782
- duration: 1000,
783
- });
776
+ customEffect: (element: Element, progress: number) => {
777
+ (element as HTMLElement).style.opacity = String(progress);
784
778
  },
785
779
  };
786
780
  ```
@@ -793,17 +787,15 @@ Defines conditional logic for interactions.
793
787
 
794
788
  ```typescript
795
789
  type Condition = {
796
- type: 'media' | 'container';
790
+ type: 'media' | 'container' | 'selector';
797
791
  predicate?: string;
798
792
  };
799
793
  ```
800
794
 
801
795
  **Properties:**
802
796
 
803
- - `type` - Type of condition check
804
- - `'media'` - Media query condition
805
- - `'container'` - Container query condition
806
- - `predicate` - The query string to evaluate
797
+ - `type` - `'media'` (media query), `'container'` (container query), or `'selector'`
798
+ - `predicate` - The query string or selector to evaluate
807
799
 
808
800
  **Examples:**
809
801
 
@@ -831,31 +823,7 @@ const wideContainer: Condition = {
831
823
  };
832
824
  ```
833
825
 
834
- ## Handler Types
835
-
836
- ### `InteractionHandlerModule`
837
-
838
- Interface for trigger handler modules.
839
-
840
- ```typescript
841
- type InteractionHandlerModule<T extends TriggerType> = {
842
- registerOptionsGetter?: (getter: () => any) => void;
843
- add: (
844
- source: HTMLElement,
845
- target: HTMLElement,
846
- effect: Effect,
847
- options: InteractionParamsTypes[T],
848
- interactOptions: InteractOptions,
849
- ) => void;
850
- remove: (element: HTMLElement) => void;
851
- };
852
- ```
853
-
854
- **Properties:**
855
-
856
- - `registerOptionsGetter` - Optional function to register global options getter
857
- - `add` - Function to add a handler for this trigger type
858
- - `remove` - Function to remove all handlers from an element
826
+ ## Trigger parameter types
859
827
 
860
828
  ### `InteractionParamsTypes`
861
829
 
@@ -865,6 +833,8 @@ Map of trigger types to their parameter types.
865
833
  type InteractionParamsTypes = {
866
834
  hover: StateParams | PointerTriggerParams;
867
835
  click: StateParams | PointerTriggerParams;
836
+ interest: StateParams | PointerTriggerParams;
837
+ activate: StateParams | PointerTriggerParams;
868
838
  viewEnter: ViewEnterParams;
869
839
  pageVisible: ViewEnterParams;
870
840
  animationEnd: AnimationEndParams;
@@ -873,27 +843,6 @@ type InteractionParamsTypes = {
873
843
  };
874
844
  ```
875
845
 
876
- ## Cache and Internal Types
877
-
878
- ### `InteractCache`
879
-
880
- Internal cache structure for parsed configuration.
881
-
882
- ```typescript
883
- type InteractCache = {
884
- effects: { [effectId: string]: Effect };
885
- conditions: { [conditionId: string]: Condition };
886
- interactions: {
887
- [key: string]: {
888
- triggers: Interaction[];
889
- effects: Record<string, (InteractionTrigger & { effect: Effect | EffectRef })[]>;
890
- interactionIds: Set<string>;
891
- selectors: Set<string>;
892
- };
893
- };
894
- };
895
- ```
896
-
897
846
  ### `TriggerParams`
898
847
 
899
848
  Union type of all trigger parameter types.
@@ -907,68 +856,6 @@ type TriggerParams =
907
856
  | AnimationEndParams;
908
857
  ```
909
858
 
910
- ## Utility Types
911
-
912
- ### `HandlerObject`
913
-
914
- Internal type for event handler management.
915
-
916
- ```typescript
917
- type HandlerObject = {
918
- source: HTMLElement;
919
- target: HTMLElement;
920
- cleanup: () => void;
921
- handler?: () => void;
922
- };
923
-
924
- type HandlerObjectMap = WeakMap<HTMLElement, Set<HandlerObject>>;
925
- ```
926
-
927
- ### Configuration Builders
928
-
929
- ```typescript
930
- // Type-safe configuration builder
931
- class InteractConfigBuilder {
932
- private config: Partial<InteractConfig> = { interactions: [], effects: {} };
933
-
934
- addInteraction(interaction: Interaction): this {
935
- this.config.interactions!.push(interaction);
936
- return this;
937
- }
938
-
939
- addEffect(id: string, effect: Effect): this {
940
- this.config.effects![id] = effect;
941
- return this;
942
- }
943
-
944
- addCondition(id: string, condition: Condition): this {
945
- if (!this.config.conditions) this.config.conditions = {};
946
- this.config.conditions[id] = condition;
947
- return this;
948
- }
949
-
950
- build(): InteractConfig {
951
- return this.config as InteractConfig;
952
- }
953
- }
954
-
955
- // Usage
956
- const config = new InteractConfigBuilder()
957
- .addEffect('fade', {
958
- duration: 1000,
959
- keyframeEffect: {
960
- name: 'fade',
961
- keyframes: [{ opacity: 0 }, { opacity: 1 }],
962
- },
963
- })
964
- .addInteraction({
965
- trigger: 'viewEnter',
966
- key: 'hero',
967
- effects: [{ effectId: 'fade' }],
968
- })
969
- .build();
970
- ```
971
-
972
859
  ## See Also
973
860
 
974
861
  - [Interact Class](interact-class.md) - Main API class