vendor/assets/javascripts/scrollspy.js in flashgrid-3.2.1 vs vendor/assets/javascripts/scrollspy.js in flashgrid-3.3.0
- old
+ new
@@ -19,11 +19,11 @@
this.$scrollElement.on('scroll.bs.scrollspy', process)
this.refresh()
this.process()
}
- ScrollSpy.VERSION = '3.2.0'
+ ScrollSpy.VERSION = '3.3.0'
ScrollSpy.DEFAULTS = {
offset: 10
}
@@ -80,12 +80,13 @@
if (scrollTop >= maxScroll) {
return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
}
- if (activeTarget && scrollTop <= offsets[0]) {
- return activeTarget != (i = targets[0]) && this.activate(i)
+ if (activeTarget && scrollTop < offsets[0]) {
+ this.activeTarget = null
+ return this.clear()
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
@@ -95,13 +96,11 @@
}
ScrollSpy.prototype.activate = function (target) {
this.activeTarget = target
- $(this.selector)
- .parentsUntil(this.options.target, '.active')
- .removeClass('active')
+ this.clear()
var selector = this.selector +
'[data-target="' + target + '"],' +
this.selector + '[href="' + target + '"]'
@@ -114,9 +113,15 @@
.closest('li.dropdown')
.addClass('active')
}
active.trigger('activate.bs.scrollspy')
+ }
+
+ ScrollSpy.prototype.clear = function () {
+ $(this.selector)
+ .parentsUntil(this.options.target, '.active')
+ .removeClass('active')
}
// SCROLLSPY PLUGIN DEFINITION
// ===========================
\ No newline at end of file