"use client";
import React, { useEffect, useRef } from "react";
import Image from "next/image";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
if (typeof window !== "undefined") {
gsap.registerPlugin(ScrollTrigger);
}
const CARDS_DATA = [
{
index: 1,
title: "Operational Visibility",
desc: "Real-time tracking and centralized control provide complete visibility across every shipment, vehicle, and delivery milestone.",
icon: (
)
},
{
index: 2,
title: "Intelligent Routing",
desc: "AI-powered route optimization reduces travel time, improves delivery accuracy, and maximizes fleet utilization.",
icon: (
)
},
{
index: 3,
title: "EV-First Logistics",
desc: "Purpose-built workflows for electric fleets improve battery efficiency, charging management, and sustainable operations.",
icon: (
)
},
{
index: 4,
title: "Scalable Network",
desc: "Flexible logistics infrastructure supports growth across cities, regions, and high-volume delivery operations without disruption.",
icon: (
)
}
];
export default function EVLogisticSection() {
const containerRef = useRef(null);
const imageWrapperRef = useRef(null);
const imageRef = useRef(null);
useEffect(() => {
const container = containerRef.current;
const img = imageRef.current;
const imgWrapper = imageWrapperRef.current;
if (!container || !img || !imgWrapper) return;
// 1. Parent Wrapper Loop: Slow Looping float
const floatAnim = gsap.to(imgWrapper, {
y: "-=10",
duration: 4.5,
ease: "sine.inOut",
yoyo: true,
repeat: -1,
});
// 2. Premium Entrance Animation on Scroll (ScrollTrigger based)
const entryTl = gsap.timeline({
scrollTrigger: {
trigger: container,
start: "top 80%",
toggleActions: "play none none none",
}
});
entryTl
.to(container.querySelector(".ev-logistic-kicker-widget"), {
opacity: 1,
y: 0,
duration: 0.8,
ease: "power3.out",
})
.to(container.querySelector(".ev-logistic-title-widget"), {
y: 0,
opacity: 1,
duration: 0.85,
ease: "power4.out",
}, "-=0.45")
.to(container.querySelectorAll(".ev-feature-card"), {
opacity: 1,
y: 0,
duration: 0.6,
stagger: 0.08,
ease: "power3.out",
}, "-=0.6")
.fromTo(img, {
opacity: 0,
scale: 0.95,
}, {
opacity: 1,
scale: 1,
duration: 1.0,
ease: "power4.out",
}, "-=0.8");
return () => {
floatAnim.kill();
};
}, []);
return (
<>