-
Notifications
You must be signed in to change notification settings - Fork 11
Description
IntersectionObserver adds a threshold parameter to allow the iteration cycle to discard nodes which don't sufficiently overlap the Rect. So for example a value of 0.0 will mean a node which intersects a rect by even 1 pixel will not be discarded, while 1.0 means the entirety of pixels would need to intersect the rect to not be discarded.
This can be ergonomically useful for developers who might end up doing these checks themselves (and in doing so can sometimes accidentally force layout). Meanwhile engines will have already flushed layout on nodes checked (to get their bounding rect) and so the intersection computation comes quite cheap (at this point in time it's essentially multiplication & division).
So this would be:
dictionary NodesFromRectOptions {
sequence<ShadowRoot> shadowRoots = [];
double threshold = 0;
}Which would allow developers to do for e.g.:
let visibleOnScreen = document.nodesFromRect(
new DOMRect(0, 0, window.screen.width, window.screen.height),
{ threshold: 0.25 }
)