aboutsummaryrefslogtreecommitdiff
path: root/dist/js/bootstrap.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-06-10 22:47:25 -0700
committerMark Otto <[email protected]>2014-06-10 22:47:25 -0700
commit57bd8f943b7768589cfa05ca8fcc8ec6cd123770 (patch)
treeab0dea1196791434e22bec140acc338918b1a9ae /dist/js/bootstrap.js
parentbc38d3b3039014cba8757e2e05857fdecbfb36be (diff)
downloadbootstrap-57bd8f943b7768589cfa05ca8fcc8ec6cd123770.tar.xz
bootstrap-57bd8f943b7768589cfa05ca8fcc8ec6cd123770.zip
grunt
Diffstat (limited to 'dist/js/bootstrap.js')
-rw-r--r--dist/js/bootstrap.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js
index f11c0fae2..279a62ded 100644
--- a/dist/js/bootstrap.js
+++ b/dist/js/bootstrap.js
@@ -1725,6 +1725,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.offsets = []
this.targets = []
this.activeTarget = null
+ this.scrollHeight = 0
this.$scrollElement.on('scroll.bs.scrollspy', process)
this.refresh()
@@ -1737,6 +1738,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
offset: 10
}
+ ScrollSpy.prototype.getScrollHeight = function () {
+ return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
+ }
+
ScrollSpy.prototype.refresh = function () {
var offsetMethod = 'offset'
var offsetBase = 0
@@ -1748,6 +1753,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.offsets = []
this.targets = []
+ this.scrollHeight = this.getScrollHeight()
var self = this
@@ -1772,13 +1778,17 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
ScrollSpy.prototype.process = function () {
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
- var scrollHeight = this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
+ var scrollHeight = this.getScrollHeight()
var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
var offsets = this.offsets
var targets = this.targets
var activeTarget = this.activeTarget
var i
+ if (this.scrollHeight != scrollHeight) {
+ this.refresh()
+ }
+
if (scrollTop >= maxScroll) {
return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
}