]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
select last item in scrollspy if you've reached the bottom of the document or element
authorJacob Thornton <jacobthornton@gmail.com>
Mon, 19 Mar 2012 22:18:00 +0000 (15:18 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Mon, 19 Mar 2012 22:18:00 +0000 (15:18 -0700)
docs/assets/bootstrap.zip
docs/assets/js/bootstrap-scrollspy.js
js/bootstrap-scrollspy.js

index 7f099d78f910d37c7b22260785b235c7fef783fb..62bfbb2671b6c0920566dc2429712ec0ee7887c1 100644 (file)
Binary files a/docs/assets/bootstrap.zip and b/docs/assets/bootstrap.zip differ
index ea29f2f866e6ead18ed53339137530d1ee52cebb..47b485785396191f3c88bf0f2ab6af766e8f1cf4 100644 (file)
 
     , process: function () {
         var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
+          , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
+          , maxScroll = scrollHeight - this.$scrollElement.height()
           , offsets = this.offsets
           , targets = this.targets
           , activeTarget = this.activeTarget
           , i
 
+        if (scrollTop >= maxScroll) {
+          return activeTarget != (i = targets.last()[0])
+            && this.activate ( i );
+        }
+
         for (i = offsets.length; i--;) {
           activeTarget != targets[i]
             && scrollTop >= offsets[i]
index ea29f2f866e6ead18ed53339137530d1ee52cebb..47b485785396191f3c88bf0f2ab6af766e8f1cf4 100644 (file)
 
     , process: function () {
         var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
+          , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
+          , maxScroll = scrollHeight - this.$scrollElement.height()
           , offsets = this.offsets
           , targets = this.targets
           , activeTarget = this.activeTarget
           , i
 
+        if (scrollTop >= maxScroll) {
+          return activeTarget != (i = targets.last()[0])
+            && this.activate ( i );
+        }
+
         for (i = offsets.length; i--;) {
           activeTarget != targets[i]
             && scrollTop >= offsets[i]