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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default Ember.Component.extend(InViewportMixin, {
viewportUseIntersectionObserver : true,
viewportScrollSensitivity : 1,
viewportRefreshRate : 150,
intersectionThreshold : 1.0,
intersectionThreshold : 0,
scrollableArea : null,
viewportTolerance: {
top : 50,
Expand Down Expand Up @@ -112,13 +112,19 @@ export default Ember.Component.extend(InViewportMixin, {
(https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
(https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/thresholds#Browser_compatibility)

- `intersectionThreshold: decimal`
- `intersectionThreshold: decimal or array`

Default: 1.0
Default: 0

A single number or array of numbers between 0.0 and 1.0. A value of 0.0 means the target will be visible when the first pixel enters the viewport. A value of 1.0 means the entire target must be visible to fire the didEnterViewport hook.
Similarily, [0, .25, .5, .75, 1] will fire didEnterViewport every 25% of the target that is visible.
(https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Thresholds)

Some notes:
- If the target is offscreen, you will get a notification via `didExitViewport` that the target is initially offscreen. Similarily, this is possible to notify if onscreen when your site loads.
- If intersectionThreshold is set to anything greater than 0, you will not see `didExitViewport` hook fired due to our use of the `isIntersecting` property. See last comment here: https://bugs.chromium.org/p/chromium/issues/detail?id=713819 for purpose of `isIntersecting`
- If your intersectionThreshold is set to 0 you will get notified if the target `didEnterViewport` and `didExitViewport` at the appropriate time.

- `scrollableArea`

Default: null
Expand Down Expand Up @@ -173,7 +179,7 @@ module.exports = function(environment) {
viewportScrollSensitivity : 1,
viewportRefreshRate : 100,
viewportListeners : [],
intersectionThreshold : 1.0,
intersectionThreshold : 0,
scrollableArea : null,
viewportTolerance: {
top : 0,
Expand Down
2 changes: 1 addition & 1 deletion addon/initializers/viewport-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const defaultConfig = {
bottom: 0,
right: 0
},
intersectionThreshold: 1.0,
intersectionThreshold: 0,
scrollableArea: null // defaults to layout view (document.documentElement)
};

Expand Down