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
Fix an edge case on IntersectionObserver #3502
Conversation
The default value for the `threshold` option is `0`, which means notify when intersectionRatio will be greater than 0. However, it generates the entry which is `intersectionRatio === 0 && isIntersected` sometimes. This causes some toots still being hidden. This issue wouldn't occur if we use `isIntersecting`, but not now for compatibility. So I've set `threshold` to clearly greater value than `0` to avoid this edge case.
Ah, this is the bug I was talking about in #3365 but couldn't remember 😞 |
Wouldn't |
Ah, yes. If the toot is longer than vertical margin, Probably |
I've done a bit of research, and the apparently the correct polyfill for I could be wrong, but the |
Hence I've implemented as But the polyfill you mentioned looks correct and we have previous value already. I will try it. |
I've tried to implement the recommended polyfill (https://github.com/nolanlawson/mastodon/commits/3502) but it seems even with this fix I can still reproduce the bug (albeit inconsistently – it's really hard to reproduce). This is hard. 😕 We might have to go with your 0.01 solution instead but I'd be shocked if there really wasn't a working polyfill for this. |
Oh, really? I cannot reproduce this bug with the polyfill (although I've used |
Actually @unarist I can't even seem to reproduce the original bug you filed. 😕 I'm trying Chrome 58 on macOS using both touchpad and sidebar scrolling, and I can't reproduce. I've even set a breakpoint for when |
I've also tested your CodePen and it seems it just turns elements pink when |
Oh, what bug did you reproduce on below comment...?
I have tested on below environment:
Also this bug seemed to occur on Android (https://mstdn.maud.io/@umezou/2357712)
No, it checks entry.target.className = !!entry.intersectionRatio; |
I have observed it on Chrome 58 on Linux, scrolling with trackpad. |
If this is only happening in Chrome, couldn't we use |
The bug where a toot would occasionally look blank.
I'm okay with this; I'm on the Edge team and so arguably it's my job to make sure this gets fixed. 😉 In the meantime checking |
My mistake; in any case my point is that the codepen does not reproduce the bug AFAICT. But I also admit this bug is really hard to reproduce. |
The default value for the
threshold
option is0
, which means notify whenintersectionRatio
will be greater than 0. However, it generates the entry which isintersectionRatio === 0 && isIntersected
sometimes. This causes some toots still being hidden.This issue wouldn't occur if we use
isIntersecting
, but not now for compatibility (#3365). So I've setthreshold
to clearly greater value than0
to avoid this edge case.cc @nolanlawson @sorin-davidoi
Example
https://codepen.io/unarist/pen/rwBxrQ/
In this example, the element with
intersectionRatio === 0
will be colored pink background. Elements you are seeing should not be colored because it is intersecting, but I can see sometimes while scrolling faster.I've confirmed this issue on Chrome 61 on Windows.