Open
Description
Currently, svelte-simple-modal assume that it's used globally. I.e., it overlays the body
element. However, sometimes it can be useful to just use it within another (scrollable) container.
To support this we could traverse the DOM tree and find the first parent that is scrollable using for instance:
const isScrollable = (element) =>
element.scrollHeight > element.clientHeight && window.getComputedStyle(element).overflowY.indexOf('hidden') === -1;
const getScrollableParent = (element) =>
!element || element === document.body
? document.body
: (isScrollable(element) ? element : getScrollableParent(element.parentNode));