File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -63,20 +63,15 @@ export function unobserve(element) {
6363
6464function onChange ( changes ) {
6565 changes . forEach ( intersection => {
66+ console . log ( intersection )
6667 if ( INSTANCE_MAP . has ( intersection . target ) ) {
6768 const { callback, visible, threshold } = INSTANCE_MAP . get (
6869 intersection . target ,
6970 )
70- let inView
71- if ( typeof intersection . isIntersecting === 'boolean' ) {
72- // Use the new "isIntersecting" property if available.
73- inView = intersection . isIntersecting
74- } else {
75- // Trigger on 0 ratio only when not visible.
76- inView = visible
77- ? intersection . intersectionRatio > threshold
78- : intersection . intersectionRatio >= threshold
79- }
71+ // Trigger on 0 ratio only when not visible.
72+ const inView = visible
73+ ? intersection . intersectionRatio > threshold
74+ : intersection . intersectionRatio >= threshold
8075
8176 INSTANCE_MAP . set ( intersection . target , {
8277 callback,
Original file line number Diff line number Diff line change @@ -38,6 +38,15 @@ storiesOf('Intersection Observer', module)
3838 </ Observer >
3939 </ ScrollWrapper >
4040 ) )
41+ . add ( 'With threshold 50%' , ( ) => (
42+ < ScrollWrapper >
43+ < Observer threshold = { 0.5 } onChange = { action ( 'Child Observer inview' ) } >
44+ { inView => (
45+ < Header > { `Header is fully inside the viewport: ${ inView } ` } </ Header >
46+ ) }
47+ </ Observer >
48+ </ ScrollWrapper >
49+ ) )
4150 . add ( 'Trigger once' , ( ) => (
4251 < ScrollWrapper >
4352 < Observer
You can’t perform that action at this time.
0 commit comments