From 6fb7092fd2961af6de35219edc2fc7467db394a7 Mon Sep 17 00:00:00 2001 From: Nicolas Venegas Date: Wed, 3 Jan 2018 16:18:34 +1100 Subject: [PATCH] Clear hash in Magellan deep linking when there is no active link. --- js/foundation.magellan.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index 1083ae39a..b31b3dd08 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -165,7 +165,11 @@ class Magellan extends Plugin { } this.$active.removeClass(this.options.activeClass); - this.$active = this.$links.filter('[href="#' + this.$targets.eq(curIdx).data('magellan-target') + '"]').addClass(this.options.activeClass); + if(curIdx !== undefined){ + this.$active = this.$links.filter('[href="#' + this.$targets.eq(curIdx).data('magellan-target') + '"]').addClass(this.options.activeClass); + }else{ + this.$active = $(); + } if(this.options.deepLinking){ var hash = ""; @@ -174,7 +178,8 @@ class Magellan extends Plugin { } if(hash !== window.location.hash) { if(window.history.pushState){ - window.history.pushState(null, null, hash); + var url = curIdx !== undefined ? hash : window.location.pathname; + window.history.pushState(null, null, url); }else{ window.location.hash = hash; } -- 2.47.2