From 6ba359ca8eaf6f24073b1e50a3ca009e170b4bfb Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 1 Apr 2020 19:53:07 +0700 Subject: [PATCH] fixed debounced cell loading --- src/components/flow/Cell/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/flow/Cell/index.tsx b/src/components/flow/Cell/index.tsx index b3ee8664..f07c9cef 100644 --- a/src/components/flow/Cell/index.tsx +++ b/src/components/flow/Cell/index.tsx @@ -35,17 +35,17 @@ const Cell: FC = ({ 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(() => {