From c0ed1fffb8258d211766a0cd595533cfdf2dee72 Mon Sep 17 00:00:00 2001
From: Chris Lawton <chris.lawton@torchbox.com>
Date: Fri, 23 Feb 2018 12:46:10 +0000
Subject: [PATCH] prevent scrolling on body when a popup is open on touch
 devices

---
 opentech/static_src/src/javascript/main.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/opentech/static_src/src/javascript/main.js b/opentech/static_src/src/javascript/main.js
index 146b1fc4f..2e8a6e549 100755
--- a/opentech/static_src/src/javascript/main.js
+++ b/opentech/static_src/src/javascript/main.js
@@ -58,6 +58,7 @@ import MobileSearch from './components/mobile-search';
         $('body').addClass('no-scroll');
         e.target.nextElementSibling.classList.add('is-open');
         $('.js-filter-list').addClass('form__filters--mobile');
+        preventTouchScroll();
     });
 
     // close mobile filters
@@ -111,6 +112,15 @@ import MobileSearch from './components/mobile-search';
         }
     }
 
+    // prevent scrolling on body when a popup is open on touch devices
+    function preventTouchScroll() {
+        $(document).on('touchmove', (e) => {
+            if ($(e.target).parents().hasClass('no-scroll')) {
+                e.preventDefault();
+            }
+        });
+    }
+
     // reset mobile filters if they're open past the tablet breakpoint
     $(window).resize(function resize(){
         if ($(window).width() < 768) {
-- 
GitLab