From c54d6e99848911699b153c8bc887e9953a1fcf92 Mon Sep 17 00:00:00 2001 From: Corey Snyder Date: Fri, 2 Feb 2018 16:02:36 -0500 Subject: [PATCH] Update foundation.magellan.js Fix for #9068 and #10384. Fires update only where there is a change. --- js/foundation.magellan.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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]); + } } /** -- 2.47.2