1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

fixed debounced cell loading

This commit is contained in:
Fedor Katurov 2020-04-01 19:53:07 +07:00
parent 133c6cd0d9
commit 6ba359ca8e

View file

@ -35,17 +35,17 @@ const Cell: FC<IProps> = ({
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);
}, [ref, is_visible, setIsVisible]);
const checkIfVisibleDebounced = useCallback(debounce(Math.random() * 200, checkIfVisible), [
const checkIfVisibleDebounced = useCallback(debounce(Math.random() * 100 + 100, checkIfVisible), [
checkIfVisible,
]);
useEffect(() => {
checkIfVisible();
checkIfVisibleDebounced();
}, []);
useEffect(() => {