"use client"; import Image from "next/image"; import { useEffect } from "react"; export default function Testimonials() { useEffect(() => { const container = document.querySelector(".circle-container"); if (!container) return; const outerElements = document.querySelectorAll(".outer-element"); const innerElements = document.querySelectorAll(".inner-element"); const testimonialElements = document.querySelectorAll(".testimonial"); let angle = 0, innerAngle = 0; const rotationSpeed = 0.0005, innerRotationSpeed = -0.001; let outerPaused = false; let innerPaused = false; let animationFrameId; function updateElementWidth() { const width = container.offsetWidth; container.style.setProperty("--circle-container-width", `${width}px`); } function updatePositions() { const containerWidth = container.offsetWidth; const outerRadius = containerWidth / 2.08; const innerRadius = containerWidth / 3.4; if (!outerPaused) { outerElements.forEach((element, index) => { const avatarAngle = angle + index * ((2 * Math.PI) / outerElements.length); element.style.transform = `translate(${ Math.cos(avatarAngle) * outerRadius }px, ${Math.sin(avatarAngle) * outerRadius}px)`; }); } if (!innerPaused) { innerElements.forEach((element, index) => { const elemAngle = innerAngle + index * ((2 * Math.PI) / innerElements.length); element.style.transform = `translate(${ Math.cos(elemAngle) * innerRadius }px, ${Math.sin(elemAngle) * innerRadius}px)`; }); } } function animate() { if (!outerPaused) angle += rotationSpeed; if (!innerPaused) innerAngle += innerRotationSpeed; updatePositions(); animationFrameId = requestAnimationFrame(animate); } function handleOuterHover(event) { if (event.type === "mouseenter") { outerPaused = true; } else { outerPaused = false; } } function handleInnerHover(event) { if (event.type === "mouseenter") { innerPaused = true; } else { innerPaused = false; } } function handleTestimonialHover(event) { const testimonial = event.currentTarget; const popup = testimonial.querySelector(".content"); if (!popup) return; const pinOffset = testimonial.getBoundingClientRect(); const pinWidth = testimonial.offsetWidth; const wrapOffset = container.getBoundingClientRect(); const popupWidth = popup.offsetWidth; const windowWidth = window.innerWidth; const windowOffsetTop = window.scrollY; const thisOffsetToWindow = pinOffset.top - windowOffsetTop; const windowHeight = window.innerHeight; if (pinOffset.left + popupWidth > windowWidth) { popup.style.left = `-${ pinOffset.left + popupWidth - windowWidth + 15 }px`; const arrow = popup.querySelector(".arrow"); if (arrow) { arrow.style.left = `${ pinOffset.left + popupWidth - windowWidth + 47 }px`; } } else { const arrow = popup.querySelector(".arrow"); if (arrow) { arrow.style.left = "auto"; } popup.style.left = "0"; } if (thisOffsetToWindow > windowHeight / 2) { popup.classList.add("top"); popup.classList.remove("bottom"); } else { popup.classList.remove("top"); popup.classList.add("bottom"); } } function handleResize() { updateElementWidth(); updatePositions(); } // Add event listeners outerElements.forEach((el) => { el.addEventListener("mouseenter", handleOuterHover); el.addEventListener("mouseleave", handleOuterHover); }); innerElements.forEach((el) => { el.addEventListener("mouseenter", handleInnerHover); el.addEventListener("mouseleave", handleInnerHover); }); testimonialElements.forEach((el) => { el.addEventListener("mouseenter", handleTestimonialHover); }); window.addEventListener("resize", handleResize); // Initialize updateElementWidth(); updatePositions(); animate(); // Cleanup return () => { cancelAnimationFrame(animationFrameId); outerElements.forEach((el) => { el.removeEventListener("mouseenter", handleOuterHover); el.removeEventListener("mouseleave", handleOuterHover); }); innerElements.forEach((el) => { el.removeEventListener("mouseenter", handleInnerHover); el.removeEventListener("mouseleave", handleInnerHover); }); testimonialElements.forEach((el) => { el.removeEventListener("mouseenter", handleTestimonialHover); }); window.removeEventListener("resize", handleResize); }; }, []); return (
TESTIMONIAL

Customer
Testimonial

Trusted by businesses and individuals, see how we’ve made a
real impact on their financial well-being
{[ { img: "/images/avatar/avatar-5.jpg", width: 100, height: 100, transform: "-434.685px, 535.12px", left: "0px", }, { img: "/images/avatar/avatar-13.jpg", width: 96, height: 96, transform: "-643.254px, -248.049px", left: "0px", }, { img: "/images/avatar/avatar-9.jpg", width: 96, height: 96, transform: "37.1317px, -688.422px", }, { img: "/images/avatar/avatar-10.jpg", width: 96, height: 96, transform: "666.203px, -177.42px", }, { img: "/images/avatar/avatar-11.jpg", width: 96, height: 96, transform: "374.604px, 578.771px", left: "-109.684px", arrowLeft: "141.684px", }, ].map((item, index) => (
avatar

Advitex provided exceptional financial guidance that transformed my investment approach. Their expertise and personalized advice made all the difference. Highly recommend!"

James Waverly

Senior Wealth Manager

))}
{[ { img: "/images/avatar/avatar-12.jpg", transform: "-75.2548px, 414.997px", position: "top", }, { img: "/images/avatar/avatar-8.jpg", transform: "75.2548px, -414.997px", position: "bottom", }, ].map((item, index) => (
avatar

Advitex provided exceptional financial guidance that transformed my investment approach. Their expertise and personalized advice made all the difference. Highly recommend!"

James Waverly

Senior Wealth Manager

))}
background
); }