# restoreScroll

function in `@dioramajs/diorama/astro/client`

```ts
import { restoreScroll } from '@dioramajs/diorama/astro/client'
```

Links back to a page land where the reader left it, as Back does; browsers open every link at
the top. A link with a #hash still goes to its anchor, and a link to the page on screen or a
form's answer to the top. Positions live in sessionStorage by path and query, kept against the
content at the top of the screen, so blocks that scripts fill above it after the swap do not
move the page. Runs before other `astro:after-swap` listeners, so Lenis, page transitions and
the site's own scripts start from the restored position, and puts the page back on that content
at `astro:page-load` and on the frame after it. Back and Forward get the same correction when
Astro restores the position the page was left at. The first call decides; it returns a
function that turns it off.

    import { restoreScroll } from '@dioramajs/diorama/astro/client'

    restoreScroll('parents')

```ts
function restoreScroll(mode: ScrollRestore): () => void
```

| Parameter | Type | Description |
| --- | --- | --- |
| `mode` | `ScrollRestore` |  |

Defined in [packages/diorama/src/astro-client.ts](https://github.com/MasterKurosava/diorama/blob/main/packages/diorama/src/astro-client.ts#L248).
