]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add _stopScrolling function to fix iOS issue.
authorBrett Mason <brettsmason@gmail.com>
Thu, 17 Nov 2016 08:41:44 +0000 (08:41 +0000)
committerBrett Mason <brettsmason@gmail.com>
Thu, 17 Nov 2016 08:41:44 +0000 (08:41 +0000)
js/foundation.offcanvas.js

index c61cc4887ddb1dd57a7e1a92688f26d6d2eeb293..08347c6b510f6b1b743429702eb489695193c8ba 100644 (file)
@@ -146,6 +146,16 @@ class OffCanvas {
     }
   }
 
+  /**
+   * Stops scrolling of the body when offcanvas is open on mobile Safari and other troublesome browsers.
+   * @private
+   */
+  _stopScrolling(event) {
+       event.preventDefault();
+       event.stopPropagation();
+       return false;
+  }
+
   /**
    * Opens the off-canvas menu.
    * @function
@@ -177,6 +187,7 @@ class OffCanvas {
 
     // If we have an overlay lets make it visible.
     if (this.options.contentOverlay) {
+       $('body').on('touchmove', this._stopScrolling);
       this.$overlay.addClass('is-visible');
     }
 
@@ -247,6 +258,7 @@ class OffCanvas {
 
     // Remove `is-visible` class from overlay.
     if (this.options.contentOverlay) {
+       $('body').off('touchmove', this._stopScrolling);
       this.$overlay.removeClass('is-visible');
     }