Edit this page

up.viewport up.reveal(element, [options])
JavaScript function

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

Fixed elements obstructing the viewport

Many applications have a navigation bar fixed to the top or bottom, obstructing the view on an element.

You can make up.reveal() aware of these fixed elements so it can scroll the viewport far enough so the revealed element is fully visible. To make up.reveal() aware of fixed elements you can either:


Parameters

element stringorElementorjQuery

The element to reveal.

[options.revealSnap] string optional

When the the revealed element would be closer to the viewport's top edge than this value, Unpoly will scroll the viewport to the top.

Set to 0 to disable snapping.

Defaults to up.viewport.config.revealSnap.

[options.viewport] stringorElementorjQuery optional

The scrolling element to scroll.

Defaults to the given element's viewport.

[options.top] boolean optional

Whether to scroll the viewport so that the first element row aligns with the top edge of the viewport.

Defaults to up.viewport.config.revealTop.

[options.behavior='instant'] string optional

When set to 'instant', this will immediately scroll to the new position.

When set to 'smooth', this will scroll smoothly to the new position.

When set to 'auto', the behavior is determined by the CSS property scroll-behavior of the viewport element.

[options.padding] number optional

The desired padding between the revealed element and the closest viewport edge (in pixels).

Defaults to up.viewport.config.revealPadding.

[options.snap] numberorboolean optional

Whether to snap to the top of the viewport if the new scroll position after revealing the element is close to the top edge.

Defaults to up.viewport.config.revealSnap.

Return value