From: Corey Snyder Date: Fri, 2 Feb 2018 21:02:36 +0000 (-0500) Subject: Update foundation.magellan.js X-Git-Tag: v6.6.0~3^2~293^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c54d6e998;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Update foundation.magellan.js Fix for #9068 and #10384. Fires update only where there is a change. --- diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index 5c0f06dd3..83192bf69 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -151,6 +151,7 @@ class Magellan extends Plugin { _updateActive(/*evt, elem, scrollPos*/) { if(this._inTransition) {return;} var winPos = /*scrollPos ||*/ parseInt(window.pageYOffset, 10), + changed = false, curIdx; if(winPos + this.winHeight === this.docHeight){ curIdx = this.points.length - 1; } @@ -166,6 +167,9 @@ class Magellan extends Plugin { this.$active.removeClass(this.options.activeClass); if(curIdx !== undefined){ + if ($(this.$active[0]).attr("href") !== $(this.$links.filter('[href="#' + this.$targets.eq(curIdx).data('magellan-target') + '"]')[0]).attr("href")) { + changed = true; + } this.$active = this.$links.filter('[href="#' + this.$targets.eq(curIdx).data('magellan-target') + '"]').addClass(this.options.activeClass); }else{ this.$active = $(); @@ -198,7 +202,9 @@ class Magellan extends Plugin { * Fires when magellan is finished updating to the new active element. * @event Magellan#update */ - this.$element.trigger('update.zf.magellan', [this.$active]); + if (changed === true) { + this.$element.trigger('update.zf.magellan', [this.$active]); + } } /**