diff --git a/docs/assets/bootstrap.zip b/docs/assets/bootstrap.zip index 4742135efa..caf293653e 100644 Binary files a/docs/assets/bootstrap.zip and b/docs/assets/bootstrap.zip differ diff --git a/docs/assets/js/bootstrap-scrollspy.js b/docs/assets/js/bootstrap-scrollspy.js index e0c74539e1..5008b0fe97 100644 --- a/docs/assets/js/bootstrap-scrollspy.js +++ b/docs/assets/js/bootstrap-scrollspy.js @@ -43,16 +43,25 @@ constructor: ScrollSpy , refresh: function () { - this.targets = this.$body + var self = this + , $targets + + this.offsets = [] + this.targets = [] + + $targets = this.$body .find(this.selector) .map(function () { var href = $(this).attr('href') - return /^#\w/.test(href) && $(href).length ? href : null + return /^#\w/.test(href) + && $(href).length + && [[ $(href).position().top, href ]] + }) + .sort(function (a, b) { return a[0] - b[0] }) + .each(function () { + self.offsets.push(this[0]) + self.targets.push(this[1]) }) - - this.offsets = $.map(this.targets, function (id) { - return $(id).position().top - }) } , process: function () { diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js index e0c74539e1..5008b0fe97 100644 --- a/js/bootstrap-scrollspy.js +++ b/js/bootstrap-scrollspy.js @@ -43,16 +43,25 @@ constructor: ScrollSpy , refresh: function () { - this.targets = this.$body + var self = this + , $targets + + this.offsets = [] + this.targets = [] + + $targets = this.$body .find(this.selector) .map(function () { var href = $(this).attr('href') - return /^#\w/.test(href) && $(href).length ? href : null + return /^#\w/.test(href) + && $(href).length + && [[ $(href).position().top, href ]] + }) + .sort(function (a, b) { return a[0] - b[0] }) + .each(function () { + self.offsets.push(this[0]) + self.targets.push(this[1]) }) - - this.offsets = $.map(this.targets, function (id) { - return $(id).position().top - }) } , process: function () {