From: Nicolas Coden Date: Sat, 17 Feb 2018 21:35:53 +0000 (+0100) Subject: fix: fire Magellan change event when there is no active link X-Git-Tag: v6.6.0~3^2~293^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbb4feec6edb8b3457f4295b843e7cde4ada50cf;p=thirdparty%2Ffoundation%2Ffoundation-sites.git fix: fire Magellan change event when there is no active link --- diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index 83192bf69..433980208 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -151,7 +151,6 @@ 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; } @@ -165,15 +164,14 @@ class Magellan extends Plugin { curIdx = curVisible.length ? curVisible.length - 1 : 0; } + var $oldActive = this.$active; 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 = $(); } + var changed = !(!this.$active.length && !$oldActive.length) && !this.$active.is($oldActive); if(this.options.deepLinking){ var hash = "";