Edit this page

API Scrolling and focus
module up.viewport

The up.viewport module controls scrolling and focus within scrollable containers ("viewports").

The default viewport for any web application is the document's scrolling element. An application may define additional viewports by giving the CSS property { overflow-y: scroll } to any block element.


Guides

Features

Essentials

All features

HTML
[up-anchored=right] stable

Marks this element as being anchored to the right edge of the screen, typically fixed navigation bars.

HTML
[up-fixed=bottom] stable

Marks this element as being fixed to the bottom edge of the screen using position: fixed.

HTML
[up-fixed=top] stable

Marks this element as being fixed to the top edge of the screen using position: fixed.

JS
up.focus(element, [options]) experimental

Focuses the given element.

HTML
.up-focus-hidden experimental

This class is assigned to elements that were focused by Unpoly but should not have a visible focus ring.

HTML
.up-focus-visible experimental

This class is assigned to elements that were focused by Unpoly and should have a visible focus ring.

JS
up.reveal(element, [options]) stable

Scrolls the given element's viewport so the first rows of the element are visible for the user.

JS
up.scroll(viewport, scrollPos, [options]) deprecated

Scrolls the given viewport to the given Y-position.

HTML
.up-scrollbar-away experimental

This class is assigned to the <body> and right-anchored elements while an overlay with a scrolling viewport is open.

HTML
[up-viewport] stable

Marks this element as a scrolling container ("viewport").

JS
up.viewport.closest(target) deprecated

Returns the scrolling container for the given element.

JS
up.viewport.config stable

Configures defaults for scrolling.

JS
up.viewport.get(target) experimental

Returns the scrolling container for the given element.

JS
up.viewport.restoreFocus([viewport], [options]) experimental

Restores previously saved focus-related state.

JS
up.viewport.restoreScroll([viewport], [options]) experimental

Restores previously saved scroll positions.

JS
up.viewport.root() experimental

Return the scrolling element for the browser's main content area.

JS
up.viewport.saveFocus([viewport], [options]) experimental

Saves focus-related state for later restoration.

JS
up.viewport.saveScroll([viewport], [options]) experimental

Saves scroll positions for later restoration.