up.scroll(viewport, scrollPos, [options])
JavaScript function
This feature has been deprecated. Use Element#scrollTo() instead.
Load unpoly-migrate.js
to polyfill deprecated features.
Scrolls the given viewport to the given Y-position.
A "viewport" is an element that has scrollbars, e.g. <body> or
a container with overflow-y: scroll.
Example
This will scroll a <div class="main">...</div> to a Y-position of 100 pixels:
up.scroll('.main', 100)
Animating the scrolling motion
The scrolling can (optionally) be animated.
up.scroll('.main', 100, { behavior: 'smooth' })
Parameters
scrollPos
required
The absolute number of pixels to set the vertical scroll position to.
Type: number
[options.behavior='instant']
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.
Type: string