- IntersectionObserver
- Last updated on
IntersectionObserverEntry.boundingClientRect
The IntersectionObserverEntry.boundingClientRect property returns a DOMRect object, with details about the element’s size and position in the viewport. All measurements are in pixels.
top/y- The distance from the top of the element to the top of the viewport.bottom- The distance from the bottom of the element to the top of the viewport.left/x- The distance from the left side of the element to the left side of the viewport.right- The distance from the right side of the element to the left side of the viewport.height- The height of the element.width- The width of the element.
let observer = new IntersectionObserver(function (entries, observer) {
for (let entry of entries) {
console.log(entry.boundingClientRect);
}
});