Skip to content
Snippets Groups Projects
Commit c0ed1fff authored by Chris Lawton's avatar Chris Lawton
Browse files

prevent scrolling on body when a popup is open on touch devices

parent b86e062f
No related branches found
No related tags found
No related merge requests found
...@@ -58,6 +58,7 @@ import MobileSearch from './components/mobile-search'; ...@@ -58,6 +58,7 @@ import MobileSearch from './components/mobile-search';
$('body').addClass('no-scroll'); $('body').addClass('no-scroll');
e.target.nextElementSibling.classList.add('is-open'); e.target.nextElementSibling.classList.add('is-open');
$('.js-filter-list').addClass('form__filters--mobile'); $('.js-filter-list').addClass('form__filters--mobile');
preventTouchScroll();
}); });
// close mobile filters // close mobile filters
...@@ -111,6 +112,15 @@ import MobileSearch from './components/mobile-search'; ...@@ -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 // reset mobile filters if they're open past the tablet breakpoint
$(window).resize(function resize(){ $(window).resize(function resize(){
if ($(window).width() < 768) { if ($(window).width() < 768) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment