# code/editor/find/settle-scroll (zidane-ui/code/editor)

Import: `import { … } from 'zidane-ui/code/editor'`. Source: [ui/src/code/editor/find/settle-scroll.ts](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/find/settle-scroll.ts).

## Functions

### `settleScroll`

Function.

Scrolls `root` so the target ends `offset` px below its top and holds it there while the content
above settles; stops on stillness, after two seconds, or when the user scrolls.

```ts
function settleScroll(
  root: HTMLElement,
  target: () => ScrollTarget,
  options?: { offset?: number | ((root: HTMLElement) => number); smooth?: boolean },
): () => void
```

**Parameters**

- `root` (`HTMLElement`): The scroll container.
- `target` (`() => ScrollTarget`): Read every frame, so it can return a freshly rendered element; `null` stops.
- `options?` (`{ offset?: number | ((root: HTMLElement) => number); smooth?: boolean }`, default `{}`): `offset`: gap above the target, or a function of `root` for one that changes;
  `smooth`: ease in over several frames (default) or jump at once.

**Returns** `() => void`: A function that cancels the scroll.

Source: [ui/src/code/editor/find/settle-scroll.ts:37](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/find/settle-scroll.ts#L37)

## Types

### `ScrollTarget`

Type.

Where to go: an element, or an estimated position in the scroll content
(`top`, in `scrollTop` terms) for a line that is not rendered yet.

```ts
type ScrollTarget = HTMLElement | { top: number } | null | undefined
```

Source: [ui/src/code/editor/find/settle-scroll.ts:25](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/find/settle-scroll.ts#L25)
