vendor/assets/js/foundation.magellan.js.es6 in foundation-rails-6.2.3.0 vs vendor/assets/js/foundation.magellan.js.es6 in foundation-rails-6.2.4.0
- old
+ new
@@ -101,10 +101,12 @@
* Function to scroll to a given location on the page.
* @param {String} loc - a properly formatted jQuery id selector. Example: '#foo'
* @function
*/
scrollToLoc(loc) {
+ // Do nothing if target does not exist to prevent errors
+ if (!$(loc).length) {return false;}
var scrollPos = Math.round($(loc).offset().top - this.options.threshold / 2 - this.options.barOffset);
$('html, body').stop(true).animate({ scrollTop: scrollPos }, this.options.animationDuration, this.options.animationEasing);
}
@@ -137,10 +139,10 @@
});
curIdx = curVisible.length ? curVisible.length - 1 : 0;
}
this.$active.removeClass(this.options.activeClass);
- this.$active = this.$links.eq(curIdx).addClass(this.options.activeClass);
+ this.$active = this.$links.filter('[href="#' + this.$targets.eq(curIdx).data('magellan-target') + '"]').addClass(this.options.activeClass);
if(this.options.deepLinking){
var hash = this.$active[0].getAttribute('href');
if(window.history.pushState){
window.history.pushState(null, null, hash);