File tree 3 files changed +5
-7
lines changed
3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as React from 'react';
2
2
import { InView } from './InView' ;
3
3
export { InView } from './InView' ;
4
4
export { useInView } from './useInView' ;
5
- export { observe , _observerMap } from './observe' ;
5
+ export { observe } from './observe' ;
6
6
7
7
export default InView ;
8
8
Original file line number Diff line number Diff line change 1
1
import { ObserverInstanceCallback } from './index' ;
2
2
3
- export const _observerMap = new Map <
3
+ const observerMap = new Map <
4
4
string ,
5
5
{
6
6
id : string ;
@@ -44,7 +44,7 @@ export function optionsToId(options: IntersectionObserverInit) {
44
44
function createObserver ( options : IntersectionObserverInit ) {
45
45
// Create a unique ID for this observer instance, based on the root, root margin and threshold.
46
46
let id = optionsToId ( options ) ;
47
- let instance = _observerMap . get ( id ) ;
47
+ let instance = observerMap . get ( id ) ;
48
48
49
49
if ( ! instance ) {
50
50
// Create a map of elements this observer is going to observe. Each element has a list of callbacks that should be triggered, once it comes into view.
@@ -85,7 +85,7 @@ function createObserver(options: IntersectionObserverInit) {
85
85
elements,
86
86
} ;
87
87
88
- _observerMap . set ( id , instance ) ;
88
+ observerMap . set ( id , instance ) ;
89
89
}
90
90
91
91
return instance ;
@@ -128,7 +128,7 @@ export function observe(
128
128
if ( elements . size === 0 ) {
129
129
// No more elements are being observer by this instance, so destroy it
130
130
observer . disconnect ( ) ;
131
- _observerMap . delete ( id ) ;
131
+ observerMap . delete ( id ) ;
132
132
}
133
133
} ;
134
134
}
Original file line number Diff line number Diff line change 1
1
import { act } from 'react-dom/test-utils' ;
2
- import { _observerMap } from './index' ;
3
2
4
3
type Item = {
5
4
callback : IntersectionObserverCallback ;
@@ -49,7 +48,6 @@ afterEach(() => {
49
48
// @ts -ignore
50
49
global . IntersectionObserver . mockClear ( ) ;
51
50
observers . clear ( ) ;
52
- _observerMap . clear ( ) ;
53
51
} ) ;
54
52
55
53
function triggerIntersection (
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon Nov 25, 2021
Successfully deployed to the following URLs: