1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-26 23:04:32 +02:00
This commit is contained in:
fat
2015-05-13 12:55:11 -07:00
parent f8b2569ec8
commit da495ee24c
4 changed files with 112 additions and 15 deletions

View File

@@ -25,7 +25,8 @@ const ScrollSpy = (($) => {
const JQUERY_NO_CONFLICT = $.fn[NAME]
const Default = {
offset : 10
offset : 10,
method : 'auto'
}
const Event = {
@@ -46,6 +47,11 @@ const ScrollSpy = (($) => {
LI : 'li'
}
const OffsetMethod = {
OFFSET : 'offset',
POSITION : 'position'
}
/**
* ------------------------------------------------------------------------
@@ -86,13 +92,14 @@ const ScrollSpy = (($) => {
// public
refresh() {
let offsetMethod = 'offset'
let offsetBase = 0
let autoMethod = this._scrollElement !== this._scrollElement.window ?
OffsetMethod.POSITION : OffsetMethod.OFFSET
if (this._scrollElement !== this._scrollElement.window) {
offsetMethod = 'position'
offsetBase = this._getScrollTop()
}
let offsetMethod = this._config.method === 'auto' ?
autoMethod : this._config.method
let offsetBase = offsetMethod === OffsetMethod.POSITION ?
this._getScrollTop() : 0
this._offsets = []
this._targets = []