diff options
| author | Jacob Thornton <[email protected]> | 2012-03-21 23:45:58 -0700 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2012-03-21 23:45:58 -0700 |
| commit | 706ee46b73b58059230b24589160da784778aad2 (patch) | |
| tree | 02ed360279f52c9891fdcad4ec50c5167188d22c /docs | |
| parent | 94b24aaa473755093677cb4eb80faf3daee53357 (diff) | |
| download | bootstrap-706ee46b73b58059230b24589160da784778aad2.tar.xz bootstrap-706ee46b73b58059230b24589160da784778aad2.zip | |
sort scrollspy to prevent flicker for unordered nav
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/assets/bootstrap.zip | bin | 55879 -> 55964 bytes | |||
| -rw-r--r-- | docs/assets/js/bootstrap-scrollspy.js | 21 |
2 files changed, 15 insertions, 6 deletions
diff --git a/docs/assets/bootstrap.zip b/docs/assets/bootstrap.zip Binary files differindex 4742135ef..caf293653 100644 --- a/docs/assets/bootstrap.zip +++ b/docs/assets/bootstrap.zip diff --git a/docs/assets/js/bootstrap-scrollspy.js b/docs/assets/js/bootstrap-scrollspy.js index e0c74539e..5008b0fe9 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 () { |
