# EffectDefinition

interface in `@dioramajs/diorama/effects`

```ts
import type { EffectDefinition } from '@dioramajs/diorama/effects'
```

What `defineEffect` takes: the params, the options and `setup`.

```ts
interface EffectDefinition<P extends ParamSpec>
```

## Members

| Name | Type | Description |
| --- | --- | --- |
| `animate?` | `AnimatePolicy<P>` | Defaults to the update's answer when it returns a boolean, else to what the effect reads: `time` animates every visible frame, `hoverTime` while hovered or hover decays, neither means 'input'. |
| `bleed?` | `number` | Extra px around the box for visibility, for copies displaced past it. Default 0. |
| `burst?` | `boolean` | Objects in `ctx.overlay` outlive a hidden or removed element while the effect still asks for frames itself (a burst): its update returned true, or its `animate` function says so. false ties them to the element: a pane or a layer of the page that only animates its state. Default true. |
| `media?` | `boolean \| 'optional'` | Needs the <img> or <video> as a texture. Implies `on: 'img, video'`, ready before setup. 'optional' reads it when the element is one and runs without it on other elements. |
| `name?` | `string` | kebab-case token in `data-dio`, e.g. `image-ripple`. Defaults to the key the effect is registered under (the file name when a build plugin finds it). |
| `on?` | `string` | Selector of the elements this effect accepts. Others are skipped with a warning. |
| `params?` | `P` | Defaults. Their types become the param types. |
| `presence?` | `'fade' \| 'custom'` | Page transitions. 'fade' (default) multiplies the copy's alpha by `u.presence`. With 'custom' the effect reads `u.presence` or `input.presence` itself. |
| `quality?` | `QualitySpec<P>` | How the effect gets cheaper on weaker GPUs. Read by the runtime and by the docs. |
| `rebuild?` | `readonly (keyof P & string)[]` | Params whose change re-runs setup. String and choice params always do. |
| `reducedMotion?` | `'static' \| 'off'` | 'static' (default) runs with motion inputs zeroed and time frozen. 'off' skips the effect. |
| `when?` | `When` | Media query the page must match or the instance is `off`. 'hover' means '(hover: hover)'. |
| `setup` | `setup(ctx: EffectContext<P>): void \| EffectUpdate \| Promise<void \| EffectUpdate>` | Builds the effect once per instance. May return an update that runs every drawn frame. |

Also exported from `@dioramajs/effects`.

Defined in [packages/effects/src/types.ts](https://github.com/MasterKurosava/diorama/blob/main/packages/effects/src/types.ts#L550).
