Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 30 additions & 19 deletions src/components/home/FeaturesSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState ,useCallback} from 'react';
Comment thread
akash-kumar-dev marked this conversation as resolved.
Outdated
import Image from 'next/image';
import { FiUsers, FiBarChart, FiShield, FiMessageCircle, FiGithub, FiClock, FiBell, FiWifi, FiCode, FiChevronLeft, FiChevronRight, FiZap } from 'react-icons/fi';
import { FaTrophy } from 'react-icons/fa';
Expand Down Expand Up @@ -102,30 +102,41 @@ const FeaturesSection = () => {
benefits: ['Automatic tracking', 'Digital wellness insights', 'Time optimization']
}
];


useEffect(() => {
intervalRef.current = setInterval(() => {
setCurrentIndex((prev) => (prev + 1) % features.length);
}, 4000);
const startAutoScroll = useCallback(() => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
}

Comment thread
akash-kumar-dev marked this conversation as resolved.
Outdated
return () => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
};
}, [features.length]);

const nextSlide = () => {
intervalRef.current = setInterval(() => {
setCurrentIndex((prev) => (prev + 1) % features.length);
};
}, 10000);
}, [features.length]);
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces new auto-scroll timing/reset behavior (clearing/restarting an interval on navigation). Please add/extend a Vitest + Testing Library test that uses fake timers to assert (1) the slide advances after the configured interval and (2) clicking next/prev resets the timer so multiple intervals don’t accumulate.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Parwathi-Jayaram, you can ignore this.

useEffect(() => {
startAutoScroll();

const prevSlide = () => {
setCurrentIndex((prev) => (prev - 1 + features.length) % features.length);
return () => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
};
}, [startAutoScroll]);

const goToSlide = (index: number) => {
setCurrentIndex(index);
};
const nextSlide = () => {
setCurrentIndex((prev) => (prev + 1) % features.length);
startAutoScroll();
};

Comment thread
akash-kumar-dev marked this conversation as resolved.
Outdated
const prevSlide = () => {
setCurrentIndex((prev) => (prev - 1 + features.length) % features.length);
startAutoScroll();
};

const goToSlide = (index: number) => {
setCurrentIndex(index);
startAutoScroll();
};

return (
<section ref={sectionRef} className="py-32 bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 relative overflow-hidden">
Expand Down
Loading