From fbb4feec6edb8b3457f4295b843e7cde4ada50cf Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sat, 17 Feb 2018 22:35:53 +0100 Subject: [PATCH] fix: fire Magellan change event when there is no active link --- js/foundation.magellan.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 = ""; -- 2.47.2