Skip to main content

.scrollTop

.scrollTop( position:Number ) : Number | void

Immediately gets/sets the scroll position (in pixels).

Parameters

  • position: Number

    The scroll position (in pixels)

Returns : Number | void

The scrollTop position in pixels (if getter) or void (if setter)

Details

Immediately gets/sets the scroll position (in pixels). If you'd like to scroll to a particular element or position smoothly, see scrollTo()

Getter

let scroll = smoother.scrollTop();

Setter

// go to a scroll position of 500
smoother.scrollTop(500);

You can use the offset() method to ascertain the position associated with a particular target element.

When you set the scroll position in this way, it will work even if paused() is true.