@wallarm-org/design-system 0.38.1 → 0.38.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,9 +4,14 @@ const COOLDOWN_MS = 200;
|
|
|
4
4
|
const useEndReached = ({ mode, scrollRef, onEndReached, threshold = TABLE_END_REACHED_THRESHOLD })=>{
|
|
5
5
|
const firedRef = useRef(false);
|
|
6
6
|
const lastFiredAtRef = useRef(0);
|
|
7
|
+
const onEndReachedRef = useRef(onEndReached);
|
|
8
|
+
useEffect(()=>{
|
|
9
|
+
onEndReachedRef.current = onEndReached;
|
|
10
|
+
});
|
|
7
11
|
useEffect(()=>{
|
|
8
|
-
if (!onEndReached) return;
|
|
9
12
|
const check = ()=>{
|
|
13
|
+
const callback = onEndReachedRef.current;
|
|
14
|
+
if (!callback) return;
|
|
10
15
|
let scrollTop;
|
|
11
16
|
let clientHeight;
|
|
12
17
|
let scrollHeight;
|
|
@@ -27,7 +32,7 @@ const useEndReached = ({ mode, scrollRef, onEndReached, threshold = TABLE_END_RE
|
|
|
27
32
|
if (!firedRef.current && now - lastFiredAtRef.current >= COOLDOWN_MS) {
|
|
28
33
|
firedRef.current = true;
|
|
29
34
|
lastFiredAtRef.current = now;
|
|
30
|
-
|
|
35
|
+
callback();
|
|
31
36
|
}
|
|
32
37
|
} else firedRef.current = false;
|
|
33
38
|
};
|
|
@@ -43,7 +48,6 @@ const useEndReached = ({ mode, scrollRef, onEndReached, threshold = TABLE_END_RE
|
|
|
43
48
|
}, [
|
|
44
49
|
mode,
|
|
45
50
|
scrollRef,
|
|
46
|
-
onEndReached,
|
|
47
51
|
threshold
|
|
48
52
|
]);
|
|
49
53
|
};
|