]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add updateHistory option to magellan
authorJake Furler <jfurler@atlassian.com>
Tue, 2 Jan 2018 05:13:18 +0000 (16:13 +1100)
committerJake Furler <jfurler@atlassian.com>
Tue, 2 Jan 2018 05:13:18 +0000 (16:13 +1100)
js/foundation.magellan.js

index c6c9c94210fda00ed25e02d3dda44819db474781..52ccd28826a374ecfde28bacddeec25c7db41468 100644 (file)
@@ -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