1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-13 17:14:04 +02:00

Scrollspy selecting the last element when at the bottom of the page (fixes #17739)

This commit is contained in:
matus
2016-01-09 03:20:40 +08:00
committed by Mark Otto
parent 8a7ce25cf1
commit 39d7861f34

View File

@@ -196,12 +196,17 @@ const ScrollSpy = (($) => {
) )
} }
_getOffsetHeight() {
return this._scrollElement === window ?
window.innerHeight : this._scrollElement.offsetHeight
}
_process() { _process() {
const scrollTop = this._getScrollTop() + this._config.offset const scrollTop = this._getScrollTop() + this._config.offset
const scrollHeight = this._getScrollHeight() const scrollHeight = this._getScrollHeight()
const maxScroll = this._config.offset const maxScroll = this._config.offset
+ scrollHeight + scrollHeight
- this._scrollElement.offsetHeight - this._getOffsetHeight()
if (this._scrollHeight !== scrollHeight) { if (this._scrollHeight !== scrollHeight) {
this.refresh() this.refresh()
@@ -213,6 +218,7 @@ const ScrollSpy = (($) => {
if (this._activeTarget !== target) { if (this._activeTarget !== target) {
this._activate(target) this._activate(target)
} }
return
} }
if (this._activeTarget && scrollTop < this._offsets[0]) { if (this._activeTarget && scrollTop < this._offsets[0]) {