Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfat <fat@folders.local>2015-05-13 22:55:11 +0300
committerfat <fat@folders.local>2015-05-13 23:15:11 +0300
commitda495ee24c239ef9c9c154670b1a641745ac147f (patch)
tree717944507c8c3450d3da3d3373551a6ac2506ac1 /js/dist/scrollspy.js
parentf8b2569ec8956a1f4d09fe6fc9865bd200ecde43 (diff)
address https://github.com/twbs/bootstrap/pull/16135
Diffstat (limited to 'js/dist/scrollspy.js')
-rw-r--r--js/dist/scrollspy.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/js/dist/scrollspy.js b/js/dist/scrollspy.js
index a748f77822..69fc579ed1 100644
--- a/js/dist/scrollspy.js
+++ b/js/dist/scrollspy.js
@@ -27,7 +27,8 @@ var ScrollSpy = (function ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME];
var Default = {
- offset: 10
+ offset: 10,
+ method: 'auto'
};
var Event = {
@@ -48,6 +49,11 @@ var ScrollSpy = (function ($) {
LI: 'li'
};
+ var OffsetMethod = {
+ OFFSET: 'offset',
+ POSITION: 'position'
+ };
+
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -81,13 +87,11 @@ var ScrollSpy = (function ($) {
value: function refresh() {
var _this = this;
- var offsetMethod = 'offset';
- var offsetBase = 0;
+ var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET;
- if (this._scrollElement !== this._scrollElement.window) {
- offsetMethod = 'position';
- offsetBase = this._getScrollTop();
- }
+ var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
+
+ var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
this._offsets = [];
this._targets = [];