body-scroll-lock
body-scroll-lock copied to clipboard
Multiple targetElements
I'm attempting to select a few targetElement
s which can be scrollable when disableBodyScroll
is enabled.
A few tests below and for some reason when I have either more than one class/ID either stated in the const or in the DOM, it no longer allows scrolling in those sections.
const targetElement = document.querySelector('.test');
const targetElement = document.querySelectorAll('.test');
const targetElement = document.querySelectorAll('nav.large, nav.small, nav.enquiries');
const targetElement = document.querySelectorAll('#navLarge, #navSmall, #navEnquiries');
bodyScrollLock.disableBodyScroll(targetElement);
If I select just one element then it works fine but in my case I need to set a few (rather than having to create a different const for every modal/popup etc).
Is there any update to this ?
Hi @richgcook @aaronstezycki - at the moment, I'm on other priorities, but if this is something that's pressing for your applications, I am happy and more likely to review your PRs for this improvement. =)
Thank you for this component solution to a very frustrating iOS issue.
I too have multiple scrolls and would benefit from disableBodyScroll handling either a single selector result or an array of selector results as the targetElement(s) parameter.
Edit: Although I now see that calling disableBodyScroll multiple times, one for each scroll #id works.