File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -123,8 +123,10 @@ function onChange(changes) {
123
123
const options = instance . options
124
124
125
125
let inView = false
126
-
127
- if ( Array . isArray ( options . threshold ) ) {
126
+ if ( intersectionRatio < 0 && isIntersecting ) {
127
+ // Firefox bug, causes intersectionRatio to sometimes be less than zero if element is larger than viewport
128
+ inView = true
129
+ } else if ( Array . isArray ( options . threshold ) ) {
128
130
// If threshold is an array, check if any of them intersects. This just triggers the onChange event multiple times.
129
131
inView = options . threshold . some ( threshold => {
130
132
return instance . visible
Original file line number Diff line number Diff line change @@ -58,6 +58,17 @@ storiesOf('Intersection Observer', module)
58
58
</ Observer >
59
59
</ ScrollWrapper >
60
60
) )
61
+ . add ( 'Taller then viewport' , ( ) => (
62
+ < ScrollWrapper >
63
+ < Observer >
64
+ { inView => (
65
+ < Header style = { { height : '150vh' } } >
66
+ Header is fully inside the viewport: { inView . toString ( ) }
67
+ </ Header >
68
+ ) }
69
+ </ Observer >
70
+ </ ScrollWrapper >
71
+ ) )
61
72
. add ( 'With threshold 100%' , ( ) => (
62
73
< ScrollWrapper >
63
74
< Observer threshold = { 1 } onChange = { action ( 'Child Observer inview' ) } >
@@ -80,6 +91,17 @@ storiesOf('Intersection Observer', module)
80
91
</ Observer >
81
92
</ ScrollWrapper >
82
93
) )
94
+ . add ( 'Taller then viewport with threshold 100%' , ( ) => (
95
+ < ScrollWrapper >
96
+ < Observer threshold = { 1 } >
97
+ { inView => (
98
+ < Header style = { { height : '150vh' } } >
99
+ Header is fully inside the viewport: { inView . toString ( ) }
100
+ </ Header >
101
+ ) }
102
+ </ Observer >
103
+ </ ScrollWrapper >
104
+ ) )
83
105
. add ( 'With threshold array' , ( ) => (
84
106
< ScrollWrapper >
85
107
< Observer
Original file line number Diff line number Diff line change @@ -3087,9 +3087,9 @@ flatten@^1.0.2:
3087
3087
version "1.0.2"
3088
3088
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
3089
3089
3090
- flow-bin@^0.61 .0 :
3091
- version "0.61 .0"
3092
- resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.61 .0.tgz#d0473a8c35dbbf4de573823f4932124397d32d35 "
3090
+ flow-bin@^0.62 .0 :
3091
+ version "0.62 .0"
3092
+ resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.62 .0.tgz#14bca669a6e3f95c0bc0c2d1eb55ec4e98cb1d83 "
3093
3093
3094
3094
flow-copy-source@^1.2.1 :
3095
3095
version "1.2.1"
You can’t perform that action at this time.
0 commit comments