Skip to content

Commit

Permalink
Scrollspy selecting the last element when at the bottom of the page (f…
Browse files Browse the repository at this point in the history
…ixes #17739)
  • Loading branch information
matus authored and mdo committed Nov 26, 2016
1 parent 8a7ce25 commit 39d7861
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,17 @@ const ScrollSpy = (($) => {
)
}

_getOffsetHeight() {
return this._scrollElement === window ?
window.innerHeight : this._scrollElement.offsetHeight
}

_process() {
const scrollTop = this._getScrollTop() + this._config.offset
const scrollHeight = this._getScrollHeight()
const maxScroll = this._config.offset
+ scrollHeight
- this._scrollElement.offsetHeight
- this._getOffsetHeight()

if (this._scrollHeight !== scrollHeight) {
this.refresh()
Expand All @@ -213,6 +218,7 @@ const ScrollSpy = (($) => {
if (this._activeTarget !== target) {
this._activate(target)
}
return
}

if (this._activeTarget && scrollTop < this._offsets[0]) {
Expand Down

0 comments on commit 39d7861

Please sign in to comment.