Skip to content

IntersectionObserver rootMargin ignored within iframe #283

Closed
@zzebastien

Description

@zzebastien

Hi,

I'm using the IntersectionObserver API within an iframe (same-origin policy) and have an issue with the 'rootMargin' option that is ignored when using 'root: null'.

I have a CodePen that demonstrate the issue, you'll see that the rootMargin set to 50px is ignored.

https://codepen.io/anon/pen/RQrBEW

The exact same code without an iframe works perfectly, so I'm wondering if this is a limitation of the API when using an iframe?

Just scroll-down in the CodePen and check the debug information on the right of the page that is displaying the result of the Intersection Observer callback.

The Intersection Observer callback is triggered as soon as "1px" of each ".component" div .isIntersecting value change, i.e. the rootMargin (here 50px) is IGNORED.

Bug is reproducible on Chrome 64.0.3282.140 (MacOS).

Note: I do NOT want to use anything else that "root: null" (or "root: document.querySelector('body')") in this scenario because I do not have any control on the content of the iframe in my application.
I know that this issue could be solved by setting the "root" value to an ancestor (div) of the components I'm observing, but as I said I cannot control the content of the iframe and could only rely on root: body or root: null.

Thanks for your time!
:)
Seb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions