diff --git a/frontend/src/components/home/Timeline.tsx b/frontend/src/components/home/Timeline.tsx index 1128240..304c10c 100644 --- a/frontend/src/components/home/Timeline.tsx +++ b/frontend/src/components/home/Timeline.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from 'react' +import React, { useLayoutEffect, useRef, useState } from 'react' import { motion, useScroll, useTransform, useInView } from 'framer-motion' import { useSite, type TimelineItem } from '../../api' import { useLang } from '../../i18n/lang' @@ -9,17 +9,17 @@ const ease = [0.23, 1, 0.32, 1] as const type Milestone = TimelineItem -function Item({ item, index, featured = false }: { item: Milestone; index: number; featured?: boolean }) { - const ref = useRef(null) +function Item({ item, index, featured = false, onLi }: { item: Milestone; index: number; featured?: boolean; onLi?: (el: HTMLLIElement | null) => void }) { + const ref = useRef(null) const active = useInView(ref, { once: true, amount: 0.6 }) const onRight = index % 2 === 0 return ( -
  • +
  • { ref.current = el; onLi?.(el) }} className={`relative md:grid md:grid-cols-2 md:gap-16 ${featured ? 'mt-10 md:mt-16' : ''}`}> {/* دایره‌ها: مرکز دایره در موبایل و دسکتاپ دقیقاً روی مرکز خط 2px است */}