Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersection Observer v2 #173

Closed
BearCooder opened this issue Sep 30, 2022 · 7 comments
Closed

Intersection Observer v2 #173

BearCooder opened this issue Sep 30, 2022 · 7 comments
Labels
focus-area-proposal Focus Area Proposal

Comments

@BearCooder
Copy link

Description

Intersection Observer v2 introduces the concept of tracking the actual "visibility" of a target element as a human being would define it. By setting an option in the IntersectionObserver constructor, intersecting IntersectionObserverEntry instances will then contain a new boolean field named isVisible. A true value for isVisible is a strong guarantee from the underlying implementation that the target element is completely unoccluded by other content and has no visual effects applied that would alter or distort its display on screen. In contrast, a false value means that the implementation cannot make that guarantee.

An important detail of the spec is that the implementation is permitted to report false negatives (that is, setting isVisible to false even when the target element is completely visible and unmodified). For performance or other reasons, browsers limit themselves to working with bounding boxes and rectilinear geometry; they don't try to achieve pixel-perfect results for modifications like border-radius.

That said, false positives are not permitted under any circumstances (that is, setting isVisible to true when the target element is not completely visible and unmodified).

The IntersectionObserver constructor now takes two additional configuration properties: delay and trackVisibility. The delay is a number indicating the minimum delay in milliseconds between notifications from the observer for a given target. The trackVisibility is a boolean indicating whether the observer will track changes in a target's visibility.

This information is from the following source

supporting links:

Delay
TrackVisibility
isVisible

v2 is supported by Chrome but not on Firefox and Safari. Its not even mentioned in the MDN doc, an open issue for the MDN doc is open here mdn/content#19201

Rationale

First time when I found out about Intersection Observer v2 I was thrilled and tested it myself just to find out its a "Chrome exclusive" for now which is a big bummer.

The great Article on web dev summarizes the benefits, an excerpt:

_Intersection Observer v2 introduces the concept of tracking the actual "visibility" of a target element as a human being would define it. By setting an option in the IntersectionObserver constructor, intersecting IntersectionObserverEntry instances will then contain a new boolean field named isVisible. A true value for isVisible is a strong guarantee from the underlying implementation that the target element is completely unoccluded by other content and has no visual effects applied that would alter or distort its display on screen. In contrast, a false value means that the implementation cannot make that guarantee.

An important detail of the spec is that the implementation is permitted to report false negatives (that is, setting isVisible to false even when the target element is completely visible and unmodified). For performance or other reasons, browsers limit themselves to working with bounding boxes and rectilinear geometry; they don't try to achieve pixel-perfect results for modifications like border-radius.

That said, false positives are not permitted under any circumstances (that is, setting isVisible to true when the target element is not completely visible and unmodified)._

Specification

https://w3c.github.io/IntersectionObserver/v2/#calculate-visibility-algo

Tests

No response

@BearCooder BearCooder added the focus-area-proposal Focus Area Proposal label Sep 30, 2022
@gsnedders gsnedders added this to the Interop 2023 milestone Oct 1, 2022
@foolip foolip moved this to Proposed in Interop 2023 Oct 7, 2022
@foolip foolip removed this from the Interop 2023 milestone Oct 7, 2022
@ghost
Copy link

ghost commented Oct 24, 2022

Looking forward to see support for v2 accross all major Browsers, I am working with animations and the delay is great for a better timing of the animations while scrolling!

@progers
Copy link

progers commented Nov 3, 2022

Chrome's usecounter is at 4.5% of pageloads (https://chromestatus.com/metrics/feature/timeline/popularity/3051) which indicates developer interest in this feature.

@foolip
Copy link
Member

foolip commented Nov 11, 2022

In the MDN short survey on APIs & JavaScript, "Intersection Observer" was selected by ~15% of survey takers, putting it in the middle third of options. (There is some uncertainty as with any survey data.)

@BearCooder
Copy link
Author

So this means that ~15% of survey takers is not enough?

@dvkam
Copy link

dvkam commented Dec 1, 2022

Chrome's usecounter is at 4.5% of pageloads (https://chromestatus.com/metrics/feature/timeline/popularity/3051) which indicates developer interest in this feature.

Btw it crossed 5%, the developer interest in v2 is here and the numbers will likely shoot up when all major browsers support it.

@nairnandu
Copy link
Contributor

Thank you for proposing Intersection Observer v2 for inclusion in Interop 2023.

We wanted to let you know that this proposal was not selected to be part of Interop this year. We had many strong proposals, and could not accept them all. However this should not be taken as a comment on the technology as a whole, and resubmitting a proposal for this feature as part of a future round of Interop would be welcome.

For an overview of our process, see the proposal selection summary. Thank you again for contributing to Interop 2023!

Posted on behalf of the Interop team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus-area-proposal Focus Area Proposal
Projects
No open projects
Status: Proposed
Development

No branches or pull requests

6 participants