body-scroll-lock icon indicating copy to clipboard operation
body-scroll-lock copied to clipboard

Multiple targetElements

Open richgcook opened this issue 6 years ago • 3 comments

I'm attempting to select a few targetElements 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).

richgcook avatar Sep 05 '18 14:09 richgcook

Is there any update to this ?

aaronstezycki avatar Oct 26 '18 12:10 aaronstezycki

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. =)

willmcpo avatar Nov 15 '18 11:11 willmcpo

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.

ghost avatar May 26 '19 00:05 ghost