Skip to main content

Module fragment

Module fragment 

Source
Expand description

Pages whose route models a #fragment open at the element it names.

The route keeps the fragment through boot normalization (#:section in its #[route]), but the browser’s own jump to it cannot be relied on: the prerendered copy it jumped in is swapped for the live app, a link inside the app changes the route without loading a page, and a page whose body is fetched renders the element only once the fetch lands. So the page scrolls itself, once the element exists, honouring prefers-reduced-motion.

Functions§

scroll_to_section
Bring the element with id to the top of the page, under the sticky nav (the target’s scroll-margin-top sets the gap), waiting up to ten seconds for it to be rendered.