From ca65e56a059f0b1878ecca11d28f884758300ac9 Mon Sep 17 00:00:00 2001 From: Jake Furler Date: Tue, 2 Jan 2018 16:13:18 +1100 Subject: [PATCH] Add updateHistory option to magellan --- js/foundation.magellan.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index c6c9c9421..52ccd2882 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -173,9 +173,13 @@ class Magellan extends Plugin { hash = this.$active[0].getAttribute('href'); } if(hash !== window.location.hash) { - if(window.history.pushState){ - window.history.pushState(null, null, hash); - }else{ + if (window.history.pushState) { + if (this.options.updateHistory) { + window.history.pushState({}, '', hash); + } else { + window.history.replaceState({}, '', hash); + } + } else { window.location.hash = hash; } } @@ -245,6 +249,13 @@ Magellan.defaults = { * @default false */ deepLinking: false, + /** + * Update the browser history with the active link, if deep linking is enabled. + * @option + * @type {boolean} + * @default true + */ + updateHistory: true, /** * Number of pixels to offset the scroll of the page on item click if using a sticky nav bar. * @option -- 2.47.2