diff --git a/hooks/useElementOnScreen.jsx b/hooks/useElementOnScreen.jsx
new file mode 100644
index 00000000000..1b3d64441bb
--- /dev/null
+++ b/hooks/useElementOnScreen.jsx
@@ -0,0 +1,30 @@
+import { useRef, useEffect, useState } from "react";
+
+const useElementOnScreen = (options) => {
+ const containerRef = useRef(null);
+ const [isVisible, setIsVisible] = useState(false);
+
+ const callbackFunction = (entries) => {
+ const [entry] = entries;
+ setIsVisible(entry.isIntersecting);
+ };
+
+ useEffect(() => {
+ const observer = new IntersectionObserver(callbackFunction, options);
+ const currentRef = containerRef.current;
+
+ if (currentRef) {
+ observer.observe(currentRef);
+ }
+
+ return () => {
+ if (currentRef) {
+ observer.unobserve(currentRef);
+ }
+ };
+ }, [options]);
+
+ return [containerRef, isVisible];
+};
+
+export default useElementOnScreen;
diff --git a/pages/index.js b/pages/index.js
index f5401ec0319..379396d2beb 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -21,6 +21,7 @@ import ThemedImage from "@components/ThemedImage";
import { serverEnv } from "@config/schemas/serverSchema";
import { PROJECT_NAME } from "@constants/index";
import Button from "@components/Button";
+import useElementOnScreen from "../hooks/useElementOnScreen.jsx";
export async function getStaticProps() {
const pageConfig = config.isr.homepage;
@@ -160,6 +161,12 @@ export default function Home({
},
];
+ const featureRefs = featuresDetails.map(() => useElementOnScreen({
+ root: null,
+ rootMargin: "0px",
+ threshold: 0.4,
+ }));
+
return (
<>