-
Notifications
You must be signed in to change notification settings - Fork 522
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
isIntersecting definition doesn't match browsers when thresholds are involved. #432
Comments
Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1611204 gecko-commit: 0dba6079675375c8934301b57a284a0988804441 gecko-integration-branch: autoland gecko-reviewers: mstange
Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1611204 gecko-commit: 867528d1d35bdec48758f8aa899b0491d7ef10e5 gecko-integration-branch: autoland gecko-reviewers: mstange
…ther browsers. r=mstange Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603
…ther browsers. r=mstange Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603
…ther browsers. r=mstange Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603
…ther browsers. r=mstange Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603
Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1611204 gecko-commit: 867528d1d35bdec48758f8aa899b0491d7ef10e5 gecko-integration-branch: autoland gecko-reviewers: mstange
…ther browsers. r=mstange Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603
…ther browsers. r=mstange Note that no browser matches the spec (see w3c/IntersectionObserver#432), but that our behavior is reasonably close to them. So do this to match them. Differential Revision: https://phabricator.services.mozilla.com/D76603
A bit of background... isIntersecting was added to handle a very specific corner case: namely, for an observer with zero as one of its thresholds, you could not distinguish between a "not intersecting" notification and an "intersecting with zero-area intersection" notification. There are two ways that a zero-area intersection can occur: target and root are edge-adjacent; or target has zero area. My initial attempt to rationalize this is #316: Here's the language around when to send a notification:
To understand this, it's helpful to consider two possibilities: either observer.thresholds contains a zero, or it does not. If observer.thresholds does not contain zero, then a change in If observer.thresholds does contain zero, then the second condition means that the transition from "not intersecting" to "intersecting with zero-area intersection" will trigger a notification to be sent as intended. Thinking about this further, I would probably prefer that
The net effect of this would be that |
One small modification -- the condition for queueing an entry can be simplified:
The condition on |
... and this would actually allow us to get entirely rid of the |
@emilio -- friendly ping, this is an important one to resolve. |
A demo for isIntersecting=true, intersectionRatio=0 |
It would be great if we would could get an agreement on this. If users make their own implementation, and expect that can just rely on the observer behaving logically with |
I think that would be sensible, and it being what Chromium does makes it probably not-problematic to change for Firefox. Do you know if there are WPTs that test this edge case? Looking at wpt.fyi I don't think I found any. But landing your PR with this tweak and a WPT test would be awesome. |
So the spec says that technically, you're supposed to set
isIntersecting
totrue
unconditionally, regardless of threshold:https://w3c.github.io/IntersectionObserver/#update-intersection-observations-algo:
It also says that we should schedule notifications whenever
isIntersecting
changes, regardless of the threshold change. However that doesn't match browsers, see:Firefox initially implemented the spec to the letter but had a workaround of sorts to make it similar to other browsers:
Given no browser follows the spec, and that Firefox is pretty close to other browsers, except on the specific value of
isIntersecting
, I think we should change the spec and Firefox, probably... But it seems kind of an unfortunate situation to be in.The text was updated successfully, but these errors were encountered: