diff --git a/app/components/AutoCarousel.tsx b/app/components/AutoCarousel.tsx index 0ab7c5f..6e8d645 100644 --- a/app/components/AutoCarousel.tsx +++ b/app/components/AutoCarousel.tsx @@ -1,14 +1,12 @@ import * as React from "react"; import Autoplay from "embla-carousel-autoplay"; +import { Card, CardContent } from "@/ui/card"; import { Carousel, CarouselContent, CarouselItem, - CarouselNext, - CarouselPrevious, - type CarouselApi, -} from "@/ui/carousel"; +} from "@/ui/carousel"; // 注意这里也移除了未使用的导入 const imageUrls = [ "/images/carousel-1.jpg", @@ -17,86 +15,58 @@ const imageUrls = [ "/images/carousel-4.jpg", "/images/carousel-5.jpg", "/images/carousel-6.jpg", - "/images/carousel-7.jpg", - "/images/carousel-8.jpg", - "/images/carousel-9.jpg", "/images/book1.png", "/images/header.png", "/images/jcdt.png", ]; export function AutoCarouselDemo() { - const [api, setApi] = React.useState(); - const [current, setCurrent] = React.useState(0); - const totalSlides = imageUrls.length; - - React.useEffect(() => { - if (!api) return; - setCurrent(api.selectedScrollSnap()); - api.on("select", () => { - setCurrent(api.selectedScrollSnap()); - }); - }, [api]); - - const getScaleByDistance = (index: number, current: number, total: number): number => { - const directDist = Math.abs(index - current); - const wrapDist = total - directDist; - const minDist = Math.min(directDist, wrapDist); - return Math.max(0.5, 1.4 - minDist * 0.15); - }; - return ( - // 最外层:允许内容溢出(关键!) -
- - {/* 内容区域也要 visible */} - - {imageUrls.map((src, index) => { - const scale = getScaleByDistance(index, current, totalSlides); - const isCurrent = scale > 1.2; +
- return ( - + + {imageUrls.map((src, index) => ( + +
- {/* 这个 div 是真正要缩放的整体卡片 */} -
- {`Slide +
+ + {`Slide +
- - ); - })} +
+ + ))} - - +
);