Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
reduce hasReached
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Dec 9, 2021
1 parent ae3af14 commit ecd072d
Showing 1 changed file with 1 addition and 3 deletions.
Expand Up @@ -16,9 +16,7 @@ const InfiniteScroll = ({ children, fetchMore, items }) => {
React.useEffect(() => {
const handler = () => {
// 念の為 2の18乗 回、最下部かどうかを確認する
const hasReached = Array.from(Array(2 ** 18), () => {
return window.innerHeight + Math.ceil(window.scrollY) >= document.body.offsetHeight;
}).every(Boolean);
const hasReached = window.innerHeight + Math.ceil(window.scrollY) >= document.body.offsetHeight

// 画面最下部にスクロールしたタイミングで、登録したハンドラを呼び出す
if (hasReached && !prevReachedRef.current) {
Expand Down

0 comments on commit ecd072d

Please sign in to comment.