A small test ground to try to see how Facebook does its modal-ish interface for creating new post.
-
We really need to know where the scrollable, parent container is. With Facebook, they have the whole body as a scrollable element. So the modal backdrop could be added with
position: fixed
. -
For complex, gridded layouts and such, it will get quite tricky. Because using a
position: fixed
modal backdrop will mean that the background is not scrollable, but the modal content is scrollable. Using aposition: absolute
modal backdrop is possible, but will need a parent that isposition: relative
, to properly wrap over the whole scrollable content. -
We can use
IntersectionObserver
to detect when user has scrolled away instead, which is a lot better thangetBoundingClientRect
. Only problem is,IntersectionObserver
is not supported in IE11, and will require a polyfill.