From: matus Date: Fri, 8 Jan 2016 19:20:40 +0000 (+0800) Subject: Scrollspy selecting the last element when at the bottom of the page (fixes #17739) X-Git-Tag: v4.0.0-alpha.6~420 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39d7861f34e01933ebee4f6b05e3ed24bca7f116;p=thirdparty%2Fbootstrap.git Scrollspy selecting the last element when at the bottom of the page (fixes #17739) --- diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 98582f9182..9b39acd362 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -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() @@ -213,6 +218,7 @@ const ScrollSpy = (($) => { if (this._activeTarget !== target) { this._activate(target) } + return } if (this._activeTarget && scrollTop < this._offsets[0]) {