CKTIS / JavaScript
IntersectionObserverEntry — reading an element's intersection
IntersectionObserverEntry describes an observed element's intersection with its root at a recorded instant. Its isIntersecting, target, and intersectionRatio properties identify the intersection state, the element, and the fraction of its area that intersects.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
entry.isIntersecting
entry.target
entry.intersectionRatioIntersectionObserverEntry is a geometry snapshot, not a continuously updated object. The browser delivers entries asynchronously to an IntersectionObserver callback; pending entries can also be retrieved through takeRecords(). The callback should process the entire entries array, not just its first entry.
IntersectionObserverEntry.target references the observed Element. IntersectionObserverEntry.isIntersecting is a boolean indicating intersection with the root. IntersectionObserverEntry.intersectionRatio is a number from 0 to 1: the area of intersectionRect divided by the area of boundingClientRect. For a zero-area target, it is 1 when isIntersecting is true, and 0 otherwise; do not treat these two properties as equivalent.
The first notification describes the initial state after observe(). Later notifications depend, among other things, on crossing configured threshold values; this is not a report of every scrolled pixel. To react at half the area, include the 0.5 threshold and test entry.isIntersecting && entry.intersectionRatio >= 0.5. Ordinary geometry observation does not prove that another element is not covering the target.
This is a browser Web API, not a feature of a particular ECMAScript edition. MDN marks the core interface as widely available since March 2019; additional features may have different support. Having Node 24 in a repository does not establish API availability. The example places a 100px-high target inside a clipping 50px-high root, then stops observing.
Examples
(() => {
const root = document.createElement('div');
root.style.cssText = 'all:initial;position:fixed;top:0;left:0;width:100px;height:50px;overflow:hidden;';
const target = document.createElement('div');
target.style.cssText = 'all:initial;display:block;width:100px;height:100px;';
root.append(target);
document.body.append(root);
const observer = new IntersectionObserver((entries) => {
for (const entry of entries) {
console.log(
entry.isIntersecting,
entry.target === target,
entry.intersectionRatio.toFixed(2)
);
}
observer.disconnect();
root.remove();
}, { root, threshold: [0, 0.5, 1] });
observer.observe(target);
})();Result
true true 0.50
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.
Sources
- IntersectionObserverEntry - Web APIs | MDN
- IntersectionObserverEntry: isIntersecting property - Web APIs | MDN
- IntersectionObserverEntry: target property - Web APIs | MDN
- IntersectionObserverEntry: intersectionRatio property - Web APIs | MDN
- Intersection Observer API - Web APIs | MDN
- IntersectionObserver: IntersectionObserver() constructor - Web APIs | MDN
- IntersectionObserver: observe() method - Web APIs | MDN