API reference up.viewport
module

Features to control scrolling and focus when fragments are updated.

The default viewport is the document's scrolling element. Mark additional scrolling containers, like a pane that scrolls on its own, with [up-viewport] so Unpoly can scroll them when revealing an element and save their scroll positions for history restoration. Elements fixed to the screen edge, like a sticky header, get [up-fixed=top] so revealed content is not hidden behind them.

From JavaScript, up.reveal() scrolls an element into view, and up.viewport.saveScroll() and up.viewport.restoreScroll() save and restore scroll positions. Defaults like the reveal padding live in up.viewport.config.


Features