]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: use `hashchange` event instead of `popstate` for IE/Edge compatibility 11011/head
authorNicolas Coden <nicolas@ncoden.fr>
Sun, 4 Mar 2018 16:29:57 +0000 (17:29 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Sun, 4 Mar 2018 16:29:57 +0000 (17:29 +0100)
See: https://github.com/zurb/foundation-sites/pull/11006#issuecomment-370193395

Previous PR: https://github.com/zurb/foundation-sites/pull/11006 (@DanielRuf)
Closes https://github.com/zurb/foundation-sites/issues/10771 (@hubert-ried)

js/foundation.accordion.js
js/foundation.magellan.js
js/foundation.reveal.js
js/foundation.tabs.js

index 7ec830bfe124511af3e1932005e43ffe376effc6..f49345d08a1a7820677e222399a229b90a2fc874 100644 (file)
@@ -146,7 +146,7 @@ class Accordion extends Plugin {
       }
     });
     if(this.options.deepLink) {
-      $(window).on('popstate', this._checkDeepLink);
+      $(window).on('hashchange', this._checkDeepLink);
     }
   }
 
@@ -265,7 +265,7 @@ class Accordion extends Plugin {
     this.$element.find('[data-tab-content]').stop(true).slideUp(0).css('display', '');
     this.$element.find('a').off('.zf.accordion');
     if(this.options.deepLink) {
-      $(window).off('popstate', this._checkDeepLink);
+      $(window).off('hashchange', this._checkDeepLink);
     }
 
   }
index 2fc40b404246cbdc5776463155ac95faf717cbc5..3cfef399e4181ccda087a19a62ff957cb74c68c4 100644 (file)
@@ -108,7 +108,7 @@ class Magellan extends Plugin {
       }
     };
 
-    $(window).on('popstate', this._deepLinkScroll);
+    $(window).on('hashchange', this._deepLinkScroll);
   }
 
   /**
@@ -222,7 +222,7 @@ class Magellan extends Plugin {
       var hash = this.$active[0].getAttribute('href');
       window.location.hash.replace(hash, '');
     }
-    $(window).off('popstate', this._deepLinkScroll);
+    $(window).off('hashchange', this._deepLinkScroll);
   }
 }
 
index 32c5d49fc2876f4a1434cd785c8cf77f753d636a..15416909209f689bfe5c6fea5ed559e6844ffc7c 100644 (file)
@@ -169,12 +169,12 @@ class Reveal extends Plugin {
       });
     }
     if (this.options.deepLink) {
-      $(window).on(`popstate.zf.reveal:${this.id}`, this._handleState.bind(this));
+      $(window).on(`hashchange.zf.reveal:${this.id}`, this._handleState.bind(this));
     }
   }
 
   /**
-   * Handles modal methods on back/forward button clicks or any other event that triggers popstate.
+   * Handles modal methods on back/forward button clicks or any other event that triggers hashchange.
    * @private
    */
   _handleState(e) {
index c6abf58dbc3325a8caabf42676b003490324933d..4382503f6d788d39964b40c0bc62b6379eb15d69 100644 (file)
@@ -94,7 +94,7 @@ class Tabs extends Plugin {
       }
     }
 
-     //current context-bound function to open tabs on page load or history popstate
+     //current context-bound function to open tabs on page load or history hashchange
     this._checkDeepLink = () => {
       var anchor = window.location.hash;
       //need a hash and a relevant anchor in this tabset
@@ -143,7 +143,7 @@ class Tabs extends Plugin {
     }
 
     if(this.options.deepLink) {
-      $(window).on('popstate', this._checkDeepLink);
+      $(window).on('hashchange', this._checkDeepLink);
     }
   }
 
@@ -394,7 +394,7 @@ class Tabs extends Plugin {
     }
 
     if (this.options.deepLink) {
-      $(window).off('popstate', this._checkDeepLink);
+      $(window).off('hashchange', this._checkDeepLink);
     }
 
   }