javascriptviewportintersection-observer

Does IntersectionObserver consider visible a div that is inside the viewport, but covered by another div?


I'm having issues with Intersection Observer and don't really know what's the problem. So I've got a question as I'm curious:

Is Intersection Observer supposed to consider A as visible when it is inside the viewport? Even though it's fully covered?

By "visible" I mean isIntersecting = true


Solution

  • Yes it does.
    To compute the intersection of a Target Element and the Root the UA only has to look at the Target element and the Root element (which is an ancestor node). Siblings don't matter, whether they cover the Target or not.

    Determining if an element is covered by another element would bring some security considerations into the mix. For instance you could use it to determine if a certain image contains transparency or not, which in turn could help determining other privacy related contents. So while it's been talked about before, I'm not sure it's still on track.