Wednesday, 30 October 2019

IntersectionObserver rootMargin's positive and negative values are not working

The code for setting the rootMargin is shown below.

let observerOptions = {
    root: null,
    rootMargin: "100px",
    threshold: []
};

When I set it to 100px, the root element's bounding box isn't growing 100px; when I set it to -100px, the root element's bounding box isn't shrinking 100px.

Here is an example on jsFiddle. The example is taken directly from MDN's documentation of IntersectionObserver, and I only changed the value of rootMargin.



from IntersectionObserver rootMargin's positive and negative values are not working

No comments:

Post a Comment