diff --git a/opentech/static_src/src/javascript/main.js b/opentech/static_src/src/javascript/main.js index 146b1fc4f90adbaf94347bd6f1847161aae08014..2e8a6e549e63d178627e47241d267f06df40671f 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) {