added cursor based pagination for links
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
const useDetectPageBottom = () => {
|
||||
const [reachedBottom, setReachedBottom] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
const offsetHeight = document.documentElement.offsetHeight;
|
||||
const innerHeight = window.innerHeight;
|
||||
const scrollTop = document.documentElement.scrollTop;
|
||||
|
||||
const hasReachedBottom = offsetHeight - (innerHeight + scrollTop) <= 100;
|
||||
|
||||
setReachedBottom(hasReachedBottom);
|
||||
};
|
||||
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
|
||||
return () => window.removeEventListener("scroll", handleScroll);
|
||||
}, []);
|
||||
|
||||
return reachedBottom;
|
||||
};
|
||||
|
||||
export default useDetectPageBottom;
|
||||
Reference in New Issue
Block a user