PageSourceSearch

https://www.accademiamoda.it/wp-content/themes/iuad-theme/src/js/custom/carousel-sedi-mobile.js?ver=1.0.0

js accademiamoda.it collected 2026-10-04 13:23:53 UTC 3,221 bytes, 96 lines download raw bytes

1/**
2 * Carousel Sedi Mobile - Infinite Loop
3 * 2 carousel con background animato, direzioni opposte
4 */
5(function() {
6    'use strict';
7
8    document.addEventListener('DOMContentLoaded', () => {
9        const carouselMobile = document.querySelector('.carousel-sedi-mobile');
10        
11        if (!carouselMobile) return;
12        
13        // Verifica che l'elemento sia visibile (non nascosto da display:none)
14        const isVisible = window.getComputedStyle(carouselMobile).display !== 'none';
15        if (!isVisible) {
16            // Se non è visibile, aspetta che diventi visibile (per template responsive dinamici)
17            const checkVisibility = () => {
18                const checkVisible = window.getComputedStyle(carouselMobile).display !== 'none';
19                if (checkVisible) {
20                    initCarouselSediMobileAnimation();
21                } else {
22                    setTimeout(checkVisibility, 100);
23                }
24            };
25            checkVisibility();
26            return;
27        }
28
29        initCarouselSediMobileAnimation();
30    });
31    
32    function initCarouselSediMobileAnimation() {
33        const carouselMobile = document.querySelector('.carousel-sedi-mobile');
34        if (!carouselMobile) return;
35        
36        // Verifica nuovamente la visibilità prima di inizializzare
37        if (window.getComputedStyle(carouselMobile).display === 'none') {
38            return;
39        }
40
41        const track1 = carouselMobile.querySelector('.carousel-track-1');
42        const track2 = carouselMobile.querySelector('.carousel-track-2');
43        
44        if (!track1 || !track2) return;
45
46        // Calcola la larghezza di un set di item (1/3 del totale)
47        const items1 = track1.querySelectorAll('.carousel-sedi-mobile-item');
48        const totalItems1 = items1.length;
49        const itemsPerSet = totalItems1 / 3;
50        
51        // Calcola larghezza di un singolo set per loop seamless
52        let setWidth = 0;
53        for (let i = 0; i < itemsPerSet; i++) {
54            setWidth += items1[i].offsetWidth;
55            if (i < itemsPerSet - 1) {
56                const gap = parseInt(window.getComputedStyle(track1).gap) || 80;
57                setWidth += gap;
58            }
59        }
60        
61        // Durata animazione (velocità diverse per non sincronizzare)
62        const duration1 = 30; // secondi
63        const duration2 = 35; // secondi (più lento)
64
65        // Animazione Carousel 1: scorre verso destra →
66        gsap.to(track1, {
67            x: -setWidth,
68            duration: duration1,
69            ease: 'none',
70            repeat: -1,
71            modifiers: {
72                x: gsap.utils.unitize(x => parseFloat(x) % setWidth)
73            }
74        });
75
76        // Animazione Carousel 2: scorre verso sinistra ←
77        gsap.fromTo(track2, 
78            {
79                x: -setWidth
80            },
81            {
82                x: 0,
83                duration: duration2,
84                ease: 'none',
85                repeat: -1,
86                modifiers: {
87                    x: gsap.utils.unitize(x => parseFloat(x) % setWidth)
88                }
89            }
90        );
91
92        //console.log('Carousel Sedi Mobile initialized');
93    }
94
95})();
96

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.