diff --git a/src/components/home/LearningPaths.tsx b/src/components/home/LearningPaths.tsx
index 3ab3e92..c5dfd25 100644
--- a/src/components/home/LearningPaths.tsx
+++ b/src/components/home/LearningPaths.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useState } from 'react';
+import { useState, useEffect, useRef } from 'react';
import { Clock, BookOpen, ArrowRight, Bell } from 'lucide-react';
import Button from '../ui/Button';
import ComingSoonBadge from '../features/ComingSoonBadge';
@@ -65,6 +65,30 @@ export default function LearningPaths() {
const [selectedPath, setSelectedPath] = useState("");
const [email, setEmail] = useState("");
const [isSubmitted, setIsSubmitted] = useState(false);
+
+ // Horizontal Infinite Scroll State Configuration
+ const [visibleCount, setVisibleCount] = useState(2);
+ const observerAnchorRef = useRef(null);
+
+ useEffect(() => {
+ const targetAnchor = observerAnchorRef.current;
+ if (!targetAnchor) return;
+
+ const scrollObserver = new IntersectionObserver((intersectEntries) => {
+ if (intersectEntries[0].isIntersecting && visibleCount < paths.length) {
+ // Smoothly load next horizontal elements block
+ setVisibleCount((prevValue) => Math.min(prevValue + 1, paths.length));
+ }
+ }, {
+ root: targetAnchor.parentElement, // Tracks scrolling within the carousel container box
+ threshold: 0.1
+ });
+
+ scrollObserver.observe(targetAnchor);
+ return () => {
+ if (targetAnchor) scrollObserver.unobserve(targetAnchor);
+ };
+ }, [visibleCount]);
const handlePathClick = (path: Path) => {
if (path.status === 'coming-soon') {
@@ -77,7 +101,6 @@ export default function LearningPaths() {
const handleNotifySubmit = (e: React.FormEvent) => {
e.preventDefault();
- // Simulate API call
setTimeout(() => {
setIsSubmitted(true);
}, 1000);
@@ -92,12 +115,12 @@ export default function LearningPaths() {
-
- {paths.map((path, index) => (
+
+ {paths.slice(0, visibleCount).map((path, index) => (
handlePathClick(path)}
>
{path.status === 'coming-soon' && }
@@ -145,6 +168,15 @@ export default function LearningPaths() {
))}
+
+ {/* Horizontal Interceptor Trigger Target Element (placed at the right end inside the slider container) */}
+
+ {visibleCount < paths.length ? (
+ 🔄
+ ) : (
+ 🎉
+ )}
+
{showNotifyModal && (
@@ -185,3 +217,4 @@ export default function LearningPaths() {
);
}
+