1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-15 10:05:40 +02:00

Added a virtual test

This commit is contained in:
matus
2016-01-09 16:40:51 +08:00
committed by Mark Otto
parent 39d7861f34
commit d328c911cb
3 changed files with 14 additions and 3 deletions

View File

@@ -182,10 +182,14 @@ var ScrollSpy = function ($) {
return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
};
ScrollSpy.prototype._getOffsetHeight = function _getOffsetHeight() {
return this._scrollElement === window ? window.innerHeight : this._scrollElement.offsetHeight;
};
ScrollSpy.prototype._process = function _process() {
var scrollTop = this._getScrollTop() + this._config.offset;
var scrollHeight = this._getScrollHeight();
var maxScroll = this._config.offset + scrollHeight - this._scrollElement.offsetHeight;
var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
if (this._scrollHeight !== scrollHeight) {
this.refresh();
@@ -197,6 +201,7 @@ var ScrollSpy = function ($) {
if (this._activeTarget !== target) {
this._activate(target);
}
return;
}
if (this._activeTarget && scrollTop < this._offsets[0]) {