Skip to content

Commit

Permalink
change intersection threshold default to 0 (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer authored Feb 18, 2018
1 parent 0c32ff7 commit 2d49c15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit 2d49c15

Please sign in to comment.