Interact pkg interact readme#214
Conversation
ameerf-wix
left a comment
There was a problem hiding this comment.
Did you use a different model or different context for this one? This one seem to be much more shallow and with some mistakes in the understanding of some of the concepts. There is also the relative-path links and some mistakes in the examples.
Also, when asking Claude it insisted that having one full example with all config+HTML+JS with as many critical features is very important. I wonder if we should have such here.
| [](https://www.npmjs.com/package/@wix/interact) | ||
| [](https://bundlephobia.com/package/@wix/interact) | ||
| [](https://github.com/wix/interact/blob/master/LICENSE) | ||
| [](https://www.npmjs.com/package/@wix/interact) |
There was a problem hiding this comment.
npm version and downloads contain the same link to npm. Maybe it is fine..
| - **Declerative** — Define trigger-to-effect bindings in JSON; no imperative event wiring | ||
| - **Web-native** — Built on CSS, WAAPI, ViewTimeline, and DOM APIs; supports DOM management via Custom Elements | ||
| - **Framework-agnostic** — Web Components and vanilla JS integrations; React integration included | ||
| - **AI-ready** — JSON configs are machine-readable and provide guardrails; LLMs can generate and agents can validate them |
There was a problem hiding this comment.
maybe a word about shipped docs and rules?
| const config = { | ||
| Interact.registerEffects(presets); // optional | ||
|
|
||
| onst config = { |
There was a problem hiding this comment.
| onst config = { | |
| const config = { |
| const interact = Interact.create(config); | ||
| ``` | ||
| // render styles - e.g. for SSR | ||
| const interactCSS = generate(config, false); |
There was a problem hiding this comment.
the example does nothing with interactCSS - implies that generate already attaches the generated CSS (which it does not)
| <!-- Wrap your target element with interact-element --> | ||
| <interact-element data-interact-key="my-element"> | ||
| <div>This will fade in when it enters the viewport!</div> | ||
| <interact-element data-interact-key="hero" data-interact-initial="true"> |
There was a problem hiding this comment.
let's verify today/tomorrow that initial is not needed anymore (or vice versa) and resolve this
| conditions: ['desktop-only'], | ||
| effects: [{ effectId: 'lift' }] | ||
| trigger: 'hover', | ||
| effects: [{ effectId: 'lift', stateAction: 'toggle' }], |
There was a problem hiding this comment.
FOUC prevention guidelines say this should have a different key, no?
| effects: { | ||
| 'follow': { | ||
| customEffect: (element, progress) => { | ||
| (element as HTMLElement).style.setProperty('--x', `${progress.x * 100}%`); |
There was a problem hiding this comment.
this is a bad example as it could be done using keyframeEffect. Also as HTMLElement is unnecessary I think. Maybe namedEffect or something that justify customEffect?
| - **`registerEffects()` must run before `Interact.create()`** when using `namedEffect`. | ||
| - **FOUC prevention requires both** — `generate(config)` injected into `<head>` AND `initial` set on the `viewEnter` + `triggerType: 'once'` element. | ||
| - **`generate(config, useFirstChild)`** — Pass `true` for `<interact-element>` (web), `false` for vanilla and React `<Interaction>`. | ||
| - **`<interact-element>` must wrap exactly one child** — the library targets `.firstElementChild` by default. |
There was a problem hiding this comment.
| - **`<interact-element>` must wrap exactly one child** — the library targets `.firstElementChild` by default. | |
| - **`<interact-element>` must wrap exactly one child** — the library targets `> :first-child` by default. |
| - [`rules/full-lean.md`](./rules/full-lean.md) — complete config spec, pitfalls, and constraints | ||
| - [`rules/integration.md`](./rules/integration.md) — entry points, lifecycle, FOUC | ||
| - [`rules/viewenter.md`](./rules/viewenter.md) — viewport entrance triggers | ||
| - [`rules/viewprogress.md`](./rules/viewprogress.md) — scroll-driven animations | ||
| - [`rules/click.md`](./rules/click.md) — click and activate triggers | ||
| - [`rules/hover.md`](./rules/hover.md) — hover and interest triggers | ||
| - [`rules/pointermove.md`](./rules/pointermove.md) — pointer-driven animations |
| - [`@wix/motion`](../motion/README.md) — low-level animation engine underneath Interact. | ||
| - [`@wix/motion-presets`](../motion-presets/README.md) — ready-made effect catalog (entrance, scroll, hover, pointer). | ||
| - [`fizban`](https://github.com/wix/fizban) — scroll-driven animation polyfill (bundled dependency). | ||
| - [`kuliso`](https://github.com/wix/kuliso) — pointer-driven animation polyfill (bundled dependency). | ||
|
|
||
| ## Documentation | ||
|
|
||
| - [**Getting Started**](./docs/guides/getting-started.md) | ||
| - [**API Reference**](./docs/api/README.md) — `Interact` class, `InteractionController`, standalone functions, types | ||
| - [**Guides**](./docs/guides/README.md) — triggers, effects, configuration, state, conditions, sequences | ||
| - [**Examples**](./docs/examples/README.md) — entrance, click, hover, list patterns | ||
| - [**React Integration**](./docs/integration/react.md) | ||
| - [**Web Components**](./docs/guides/custom-elements.md) | ||
| - [**Full Documentation Index**](./docs/README.md) | ||
|
|
Description
README for the Interact package