diff options
| author | fat <[email protected]> | 2015-05-13 12:55:11 -0700 |
|---|---|---|
| committer | fat <[email protected]> | 2015-05-13 13:15:11 -0700 |
| commit | da495ee24c239ef9c9c154670b1a641745ac147f (patch) | |
| tree | 717944507c8c3450d3da3d3373551a6ac2506ac1 /js/src | |
| parent | f8b2569ec8956a1f4d09fe6fc9865bd200ecde43 (diff) | |
| download | bootstrap-da495ee24c239ef9c9c154670b1a641745ac147f.tar.xz bootstrap-da495ee24c239ef9c9c154670b1a641745ac147f.zip | |
address https://github.com/twbs/bootstrap/pull/16135
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/scrollspy.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index d1be3a45f..3f4a145a1 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -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 = [] |
