Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

@dioramajs/diorama/astro/client

Exports of @dioramajs/diorama/astro/client.

View as Markdown
On this page
import { restoreScroll, smoothScroll } from '@dioramajs/diorama/astro/client'

Functions

restoreScrollLinks 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.
smoothScrollSmooth scroll on an Astro page. 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>.

Interfaces

SmoothScrollThe part of Lenis 1.3 the page side uses on top of what the adapter needs.

Types

ScrollRestoreWhich ClientRouter links land where the reader left the page, as Back does, instead of at the top. 'parents': links up the address, to `/` from anywhere or to `/work` from `/work/aurora`, so a list opens where the reader left it while a project opened from it starts at its cover. 'visited': links to any page seen earlier in this tab.