From 21b37254735d16a05d61b84ecbc74acf946fa622 Mon Sep 17 00:00:00 2001 From: Brett Mason Date: Thu, 17 Nov 2016 08:41:44 +0000 Subject: [PATCH] Add _stopScrolling function to fix iOS issue. --- js/foundation.offcanvas.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/foundation.offcanvas.js b/js/foundation.offcanvas.js index c61cc4887..08347c6b5 100644 --- a/js/foundation.offcanvas.js +++ b/js/foundation.offcanvas.js @@ -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'); } -- 2.47.2