]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Scrollspy selecting the last element when at the bottom of the page (fixes #17739)
authormatus <matus@ventes.io>
Fri, 8 Jan 2016 19:20:40 +0000 (03:20 +0800)
committerMark Otto <markdotto@gmail.com>
Sat, 26 Nov 2016 01:38:42 +0000 (17:38 -0800)
js/src/scrollspy.js

index 98582f91820e0cdc350c389ae1f698339cb76310..9b39acd3628ac613864c1427fe31273c60596c96 100644 (file)
@@ -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]) {