smoothScroll function
Smooth scroll on an Astro page.
import { smoothScroll } from '@dioramajs/diorama/astro/client'The first call makes the page's Lenis, later calls return it, so a script that needs the instance calls it too. Lenis runs on its own frames until the app of start() runs and drives it. On a ClientRouter swap it keeps the scroll Astro sets (the top, the hash, the position Back restores) and its classes on <html>.
import Lenis from 'lenis'import { smoothScroll } from '@dioramajs/diorama/astro/client'
const lenis = smoothScroll(Lenis, { easing: (t) => 1 - (1 - t) ** 3, duration: 1.2 })function smoothScroll<O extends object, L extends SmoothScroll>(
Lenis: (options?: O) => L,
options?: O,
): LParameters
| Name | Type | Description |
|---|---|---|
Lenis | (options?: O) => L | |
options? | O |
Defined in packages/diorama/src/astro-client.ts.