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

change intersection threshold default to 0 #126

Merged
merged 3 commits into from
Feb 18, 2018
Merged

change intersection threshold default to 0 #126

merged 3 commits into from
Feb 18, 2018

Conversation

snewcomer
Copy link
Collaborator

To be inline with the IntersectionObserver spec, I think we should make the threshold value default to 0, meaning the didEnterViewport will trigger when the first pixel of the target has entered the scrollable area.

@snewcomer snewcomer self-assigned this Feb 17, 2018
@snewcomer
Copy link
Collaborator Author

snewcomer commented Feb 17, 2018

Also, there may be one big reason for this (that is outside of infinite scrolling). isIntersecting return true, even when the element is scrolled outside of the viewport (if threshold is anything > 0). When threshold is configured to 0/not configured at all, isIntersecting is false when it fails the threshold value as it is scrolled out of the viewport. This is due to why isIntersecting was created - see links below. Gist of it is zero-area elements have an intersectionRatio of 1 by default so can be used to detect isIntersecting.

Turns out this is how it was supposed to be intended.

w3c/IntersectionObserver#165
https://bugs.chromium.org/p/chromium/issues/detail?id=713819

@snewcomer snewcomer changed the title change intersection threshold to 0 change intersection threshold default to 0 Feb 17, 2018
@snewcomer snewcomer merged commit 2d49c15 into master Feb 18, 2018
@snewcomer snewcomer deleted the threshold-0 branch February 18, 2018 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant