<!-- Source: https://motion.svelte.page/docs/create-scoped-animate -->

# createScopedAnimate

> Create an animate function bound to a scope element — the factory useAnimate is built on.

**Source:** [https://motion.svelte.page/docs/create-scoped-animate](https://motion.svelte.page/docs/create-scoped-animate)

---

`createScopedAnimate` creates an `animate` function bound to a scope element and settings. Selector strings resolve inside `scope.current` instead of the whole document, and every animation it starts is pushed onto `scope.animations`. It is the factory [`useAnimate()`](/docs/use-animate) is built on, re-exported unchanged from Motion.

> Live example: [/examples/create-scoped-animate](https://motion.svelte.page/examples/create-scoped-animate)

## Usage

```ts
import { createScopedAnimate } from '@humanspeak/svelte-motion'

const card = document.querySelector('.card')!
const animateCard = createScopedAnimate({ scope: { current: card, animations: [] } })

// Only the .chip elements inside .card move.
animateCard('.chip', { x: 100 }, { duration: 0.4 })
```

## Options

| Option | Default | Description |
|---|---|---|
| `scope` | none | `{ current, animations }`. Selectors resolve inside `current`; started animations are pushed onto `animations`. Accepts the scope from `useAnimate()`. |
| `reduceMotion` | `undefined` | When `true`, transform and layout values animate instantly, as `MotionConfig reducedMotion="always"` does. |
| `skipAnimations` | `undefined` | When `true`, every animation jumps straight to its final value. |

## When to use it instead of useAnimate

Use [`useAnimate()`](/docs/use-animate) inside components: it wires the scope as an attachment, follows the nearest `MotionConfig`, and stops its animations when the element detaches.

Reach for `createScopedAnimate` outside components (actions, attachments, plain `.ts` modules) or when you own the element's lifecycle. Its `scope` only collects animations; it doesn't stop them. Call `stop()` on each entry in `scope.animations` when you tear the element down.

The exception is an active [`scopeMotion`](/docs/scope-motion) scope. A scoped animate called while one runs (inside a `useScopeMotion` setup, `scope.current.run()`, or a handler bound with `bind()`) registers each timeline with that scope. The timeline stops when the scope is cancelled, the same as upstream (`framer-motion/src/animation/animate/index.ts`: `motionScope.add(() => timeline.stop())`).

```ts
for (const animation of scope.animations) animation.stop()
scope.animations.length = 0
```

## Returns

A function with the same call shapes as [`animate`](/docs/api-reference): elements and selectors, motion values, objects, and sequences. Every call returns a mutable `Timeline` (Motion 14.7).

Unlike the module-level `animate`, the scoped function has no `addEffect` / `removeEffect` statics. Register effects on `animate` itself.
