跳过主要内容

.scrollTop

.scrollTop( position:Number ) : Number | void

立即获取/设置滚动位置(以像素为单位)。

参数

  • 位置: 数值

    滚动位置(以像素为单位)

返回值:数字 | 无

滚动条顶部位置,以像素为单位(如果是取值器)或无(如果是赋值器)

细节

立即获取或设置滚动位置(以像素为单位)。如果您希望平滑滚动到特定元素或位置,请参见或 scrollTo()

获取器

let scroll = smoother.scrollTop();

设置器

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

您可以使用offset()方法来确定与特定目标元素相关联的位置。

当你通过这种方式设置滚动位置时,即使paused()设置为true.