app/assets/javascripts/twitter/bootstrap/scrollspy.js in less-rails-bootstrap-3.2.0 vs app/assets/javascripts/twitter/bootstrap/scrollspy.js in less-rails-bootstrap-3.3.0.0

- old
+ new

@@ -1,7 +1,7 @@ /* ======================================================================== - * Bootstrap: scrollspy.js v3.2.0 + * Bootstrap: scrollspy.js v3.3.0 * http://getbootstrap.com/javascript/#scrollspy * ======================================================================== * Copyright 2011-2014 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ @@ -28,11 +28,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 } @@ -89,12 +89,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] @@ -104,13 +105,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 + '"]' @@ -123,9 +122,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 // ===========================