From: Jake Furler Date: Tue, 2 Jan 2018 05:13:18 +0000 (+1100) Subject: Add updateHistory option to magellan X-Git-Tag: v6.6.0~3^2~325^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca65e56a059f0b1878ecca11d28f884758300ac9;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Add updateHistory option to magellan --- 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