mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
fixed debounced cell loading
This commit is contained in:
parent
133c6cd0d9
commit
6ba359ca8e
1 changed files with 4 additions and 4 deletions
|
@ -35,17 +35,17 @@ const Cell: FC<IProps> = ({
|
||||||
|
|
||||||
const { top, height } = ref.current.getBoundingClientRect();
|
const { top, height } = ref.current.getBoundingClientRect();
|
||||||
|
|
||||||
const visibility = top + height > -window.innerHeight && top < window.innerHeight * 2;
|
// const visibility = top + height > -window.innerHeight && top < window.innerHeight * 2;
|
||||||
|
const visibility = top + height > -600 && top < window.innerHeight + 600;
|
||||||
if (visibility !== is_visible) setIsVisible(visibility);
|
if (visibility !== is_visible) setIsVisible(visibility);
|
||||||
}, [ref, is_visible, setIsVisible]);
|
}, [ref, is_visible, setIsVisible]);
|
||||||
|
|
||||||
const checkIfVisibleDebounced = useCallback(debounce(Math.random() * 200, checkIfVisible), [
|
const checkIfVisibleDebounced = useCallback(debounce(Math.random() * 100 + 100, checkIfVisible), [
|
||||||
checkIfVisible,
|
checkIfVisible,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkIfVisible();
|
checkIfVisibleDebounced();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue