Impossible to reproduce the clickup carousel animation

its seems impossible to reproduce the carousel of clickup saas… Anyone can help me please ?

the carousel
https://clickup.com/

There is my actual code :

<!DOCTYPE html>
<html lang="fr">
   <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Carousel</title>
      <style>
         body {
         font-family: Arial, sans-serif;
         background-color: #f0f0f5;
         display: flex;
         justify-content: center;
         align-items: center;
         height: 100vh;
         margin: 0;
         }
         .carousel-wrapper {
         position: relative;
         width: 70%;
         margin: 0 auto;
         display: flex;
         align-items: center;
         }
         .carousel-container {
         overflow: hidden;
         width: 100%;
         display: flex;
         justify-content: center;
         position: relative;
         padding-left: 100px;
         padding-right: 100px;
         }
         .carousel {
         display: flex;
         transition: transform 0.5s ease-in-out;
         position: relative;
         }
         .carousel-item {
         display: flex;
         flex-direction: column;
         align-items: center;
         justify-content: center;
         text-align: center;
         margin: 0 30px;
         padding: 20px;
         background-color: #fff;
         border-radius: 10px;
         box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
         opacity: 0.6;
         transition: opacity 0.3s ease, transform 0.3s ease-in-out;
         cursor: pointer;
         width: 150px;
         }
         .carousel-item:hover {
         transform: translateY(-5px);
         }
         .carousel-item.active {
         opacity: 1;
         transform: scale(1.1);
         box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
         }
         .fade-left, .fade-right {
         position: absolute;
         top: 0;
         bottom: 0;
         width: 100px;
         pointer-events: none;
         }
         .fade-left {
         left: 0;
         background: linear-gradient(to right, rgba(240, 240, 245, 1), rgba(240, 240, 245, 0));
         }
         .fade-right {
         right: 0;
         background: linear-gradient(to left, rgba(240, 240, 245, 1), rgba(240, 240, 245, 0));
         }
         .fa-duotone {
         font-size: 50px;
         color: #333;
         }
      </style>
   </head>
   <body>
      <div class="carousel-wrapper">
         <div class="fade-left"></div>
         <div class="carousel-container">
            <div class="carousel">
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-image"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-subtitles" style="--fa-primary-color: #000;"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-link"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-file-code"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-file-pen"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-wand-magic-sparkles"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-circle-question"></i></div>
               <!-- Dupliquer les éléments pour créer un effet continu -->
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-image"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-subtitles" style="--fa-primary-color: #000;"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-link"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-file-code"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-file-pen"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-wand-magic-sparkles"></i></div>
               <div class="carousel-item"><i class="fa-duotone fa-solid fa-circle-question"></i></div>
            </div>
         </div>
         <div class="fade-right"></div>
      </div>
      <script>
         const carousel = document.querySelector('.carousel');
         const items = document.querySelectorAll('.carousel-item');
         const visibleItems = 7; // Le nombre d'éléments visibles
         let currentIndex = Math.floor(items.length / 3); // Index de l'élément central initial
         
         function updateCarousel(newIndex) {
             const middleIndex = Math.floor(visibleItems / 2);
             const offset = newIndex - currentIndex;
         
             if (newIndex < 0 || newIndex >= items.length) return;
         
             const itemWidth = items[0].offsetWidth + 60;
         
             // Déplacer le carrousel pour centrer le nouvel élément cliqué
             carousel.style.transform = `translateX(${-(newIndex - middleIndex) * itemWidth}px)`;
         
             // Mettre à jour la classe active
             items[currentIndex].classList.remove('active');
             items[newIndex].classList.add('active');
         
             currentIndex = newIndex; // Mettre à jour l'index courant
         }
         
         // Ajouter l'événement de clic à chaque élément du carrousel
         items.forEach((item, index) => {
             item.addEventListener('click', () => {
                 updateCarousel(index);
             });
         });
         
         // Initialiser la position du carrousel
         items[currentIndex].classList.add('active');
         carousel.style.transform = `translateX(${-(currentIndex - Math.floor(visibleItems / 2))     * (items[0].offsetWidth + 60)}px)`;
      </script>
   </body>
</html>

But i have already try many things.

So, to recap, I’m trying to create a carousel where 7 elements are visible at the same time, with the 4th element always centered. When a user clicks on an element to the right or left of the center, that element should move to take the central position. For example, if I click on an element that’s to the right of the center, that element should move to the center. The same behavior should occur if an element to the left of the center is clicked. The movement should be smooth and maintain the order of the elements, without scrolling through the entire carousel. Basically, just like ClickUp.

Thanks for any help !


Try & test

Moving Based on Initial and Target Index
Problem: Movement was fixed in increments of 7 items, causing inconsistent shifts and incorrect centering of items.

Absolute Pixel Calculation for Movement
Problem: Used fixed pixel values for movement, resulting in incorrect display and misalignment of centered items.

Using currentOffset for Position Calculation
Problem: Incorrect initial positioning led to misalignment and improper centering of items.

CSS Animation for Pixel Movement
Problem: CSS animations were out of sync with JavaScript calculations, causing display issues.

Recalculation Based on Clicks
Problem: Miscalculated the pixel movement needed, leading to improper centering and alignment.

Initial Centering with Movement Calculation
Problem: Incorrect initial centering resulted in the wrong element being centered and displayed.

Direct translateX Manipulation
Problem: Directly manipulating translateX with incorrect values led to inconsistent movement and centering.

And many other things…

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật