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

Unclear content for the Intersection Observer API #37756

Open
haocheng6 opened this issue Jan 22, 2025 · 1 comment
Open

Unclear content for the Intersection Observer API #37756

haocheng6 opened this issue Jan 22, 2025 · 1 comment
Labels
area: Resize/Intersection Observer Content:WebAPI Web API docs good first issue A good issue for newcomers to get started with.

Comments

@haocheng6
Copy link
Contributor

haocheng6 commented Jan 22, 2025

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API

What specific section or headline is this issue about?

Intersection change callbacks

What information was incorrect, unhelpful, or incomplete?

The page says

Each entry in the list of thresholds is an IntersectionObserverEntry object describing one threshold that was crossed; that is, each entry describes how much of a given element is intersecting with the root element, whether or not the element is considered to be intersecting or not, etc.

But I don't understand how each entry in the list of thresholds is an object. Each entry in the list of thresholds should be just a threshold which is a number. The sentence seems incomplete to me.

What did you expect to see?

I expect to see the quoted sentence above is corrected to avoid confusion.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@haocheng6 haocheng6 added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 22, 2025
@github-actions github-actions bot added the Content:WebAPI Web API docs label Jan 22, 2025
@Josh-Cena
Copy link
Member

Instead of these two paragraphs, which explains the same thing twice, the second time in an imprecise way:

The list of entries received by the callback includes one entry for each threshold-crossing event — multiple entries can be received at a time, either from multiple targets or from a single target crossing multiple thresholds in a short amount of time. The entries are dispatched using a queue, so they should be ordered by the time they were generated, but you should preferably use IntersectionObserverEntry.time to correctly order them.

Each entry in the list of thresholds is an IntersectionObserverEntry object describing one threshold that was crossed; that is, each entry describes how much of a given element is intersecting with the root element, whether or not the element is considered to be intersecting or not, etc. The entry only contains information about that particular instant — if you want information that requires tracking over time, such as the scroll direction and speed, you may need to compute that yourself by memorizing previously received entries.

We should merge them:

The list of entries received by the callback includes one IntersectionObserverEntry object for each threshold-crossing event — multiple entries can be received at a time, either from multiple targets or from a single target crossing multiple thresholds in a short amount of time. The entries are dispatched using a queue, so they should be ordered by the time they were generated, but you should preferably use IntersectionObserverEntry.time to correctly order them. Each entry describes how much of a given element is intersecting with the root element, whether or not the element is considered to be intersecting or not, etc. The entry only contains information about that particular instant — if you want information that requires tracking over time, such as the scroll direction and speed, you may need to compute that yourself by memorizing previously received entries.

@Josh-Cena Josh-Cena added good first issue A good issue for newcomers to get started with. area: Resize/Intersection Observer and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Resize/Intersection Observer Content:WebAPI Web API docs good first issue A good issue for newcomers to get started with.
Projects
None yet
Development

No branches or pull requests

2 participants