diff --git a/src/components/about/animated-testimonials.tsx b/src/components/about/animated-testimonials.tsx
index 0c96d34..78ea48f 100644
--- a/src/components/about/animated-testimonials.tsx
+++ b/src/components/about/animated-testimonials.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef } from 'react'
+import { useEffect, useRef, useState } from 'react'
interface TestimonialAuthor {
name: string
@@ -14,19 +14,42 @@ interface Testimonial {
interface AnimatedTestimonialProps {
testimonial: Testimonial
+ index: number
}
-const AnimatedTestimonials = ({ testimonial }: AnimatedTestimonialProps) => {
+const ITEMS_PER_COLUMN = 3
+
+const AnimatedTestimonials = ({
+ testimonial,
+ index,
+}: AnimatedTestimonialProps) => {
const testimonialRef = useRef
(null)
+ const [isDesktop, setIsDesktop] = useState(false)
useEffect(() => {
- if (window.innerWidth >= 640) return
+ setIsDesktop(window.innerWidth >= 640)
+ }, [])
+ useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
- if (entry.isIntersecting) {
- if (testimonialRef.current) {
+ if (entry.isIntersecting && testimonialRef.current) {
+ if (isDesktop) {
+ const columnIndex = Math.floor(index / ITEMS_PER_COLUMN)
+ setTimeout(() => {
+ if (testimonialRef.current) {
+ testimonialRef.current.classList.remove(
+ 'opacity-0',
+ 'translate-y-4',
+ )
+ testimonialRef.current.classList.add(
+ 'opacity-100',
+ 'translate-y-0',
+ )
+ }
+ }, columnIndex * 200)
+ } else {
testimonialRef.current.classList.remove(
'opacity-0',
'translate-y-8',
@@ -53,12 +76,14 @@ const AnimatedTestimonials = ({ testimonial }: AnimatedTestimonialProps) => {
return () => {
observer.disconnect()
}
- }, [])
+ }, [isDesktop, index])
+
+ const initialTransform = isDesktop ? 'translate-y-4' : 'translate-y-8'
return (