1- < section id ="partners ">
2- < div id ="partnerCarousel " class ="carousel slide " data-ride ="carousel ">
3-
1+ < section id ="partners " style ="overflow: hidden; padding: 5vh 0; background-color: #000; ">
2+ < div class ="col-12 margin-top " style ="text-align: center; margin-top: 3vh; ">
3+ < h1 style ="font-size: 5vh; text-align: center; width: 100%; " class ="partners-title "> < b > Partners</ b > que apoyan a la comunidad</ h1 >
4+ </ div >
5+ < div class ="row " style ="margin-bottom: 5vh; ">
6+ < div class ="col-12 " style ="text-align: center; ">
7+ < h1 style ="text-align: center; width: 100%; margin-bottom: 1vh; padding-bottom: 0; "> ¡Más de
8+ {{ site.confidents | size | minus: 1 }} empresas y proyectos < b > confían</ b > en nosotros!
9+ </ h1 >
10+ < a href ="#contact " class ="headerButton " style ="display: inline-block; margin-top: 1vh; position: relative; "> ¡Quiero ser parte!</ a >
11+ </ div >
12+ </ div >
413
14+ < div class ="carousel-container " style ="position: relative; overflow: hidden; height: 15vh; ">
15+ < div class ="carousel-track " id ="carouselTrack " style ="display: flex; align-items: center; gap: 5vw; ">
16+ <!-- Los partners se generarán aquí -->
17+ </ div >
18+ </ div >
519
6- < div class ="row ">
7- < div class ="col-9 ">
8- < h1 > ¡Más de
9- {{ site.confidents | size | minus: 1 }} empresas y proyectos < b > confían</ b > en nosotros!
10- </ h1 >
11- </ div >
12- < div class ="col-3 ">
13- < a href ="#contact " class ="headerButton "> ¡Quiero ser parte!</ a >
14- </ div >
20+ < div class ="carousel-container " style ="position: relative; overflow: hidden; height: 15vh; ">
21+ < div class ="carousel-track " id ="carouselTrack " style ="display: flex; align-items: center; gap: 5vw; ">
22+ <!-- Los partners se generarán aquí -->
1523 </ div >
24+ </ div >
1625
17- < div class ="carousel-inner " id ="carouselInner ">
26+ < style >
27+ .carousel-track {
28+ width : fit-content;
29+ animation : none;
30+ }
1831
19- </ div >
32+ .partner-item {
33+ flex : 0 0 auto;
34+ display : flex;
35+ flex-direction : column;
36+ align-items : center;
37+ text-align : center;
38+ min-width : 150px ;
39+ }
2040
21- </ div >
41+ .partner-item img {
42+ max-width : 80px ;
43+ max-height : 60px ;
44+ object-fit : contain;
45+ margin-bottom : 1vh ;
46+ }
2247
23- < script >
24- $ ( '#partnerCarousel' ) . carousel ( {
25- interval : 2500
26- } )
27-
28- const data = { { site . confidents | jsonify} }
29-
30- const carouselInner = document . getElementById ( "carouselInner" )
31- const groups = Math . ceil ( data . length / 4 )
32-
33-
34- for ( let i = 0 ; i < groups ; i ++ ) {
35-
36- const groupInfo = data . slice ( i * 4 , ( i + 1 ) * 4 )
37- const carouselItem = document . createElement ( "div" )
38- const carouselRow = document . createElement ( "div" )
39- carouselItem . classList . add ( "carousel-item" )
40- carouselRow . classList . add ( "row" )
41- carouselItem . appendChild ( carouselRow )
42- if ( i == 0 ) carouselItem . classList . add ( "active" )
43-
44- groupInfo . forEach ( confident => {
45- carouselRow . insertAdjacentHTML ( "beforeend" , `
46- <div class="col-3">
47- <a href="${ confident . customURL } " target="_blank">
48- <img src="${ confident . icon } " alt="">
49- <p>${ confident . name } </p>
50- </a>
51- </div>
52- ` )
53- } ) ;
48+ .partner-item p {
49+ font-size : 1.4vh ;
50+ margin : 0 ;
51+ opacity : 0.8 ;
52+ color : white;
53+ }
5454
55- carouselInner . appendChild ( carouselItem )
55+ .partner-item a {
56+ text-decoration : none;
57+ color : inherit;
58+ transition : opacity 0.3s ;
59+ }
5660
61+ .partner-item a : hover {
62+ opacity : 0.7 ;
5763 }
64+ </ style >
65+
66+ < script >
67+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
68+ const data = { { site . confidents | jsonify } } ;
69+ const carouselTrack = document . getElementById ( "carouselTrack" ) ;
70+
71+ // Duplicamos los datos
72+ const duplicatedData = [ ...data , ...data ] ;
73+
74+ duplicatedData . forEach ( confident => {
75+ const partnerItem = document . createElement ( "div" ) ;
76+ partnerItem . classList . add ( "partner-item" ) ;
77+
78+ partnerItem . innerHTML = `
79+ <a href="${ confident . customURL } " target="_blank">
80+ <img src="${ confident . icon } " alt="${ confident . name } ">
81+ <p>${ confident . name } </p>
82+ </a>
83+ ` ;
84+
85+ carouselTrack . appendChild ( partnerItem ) ;
86+ } ) ;
87+
88+ // Iniciamos la animación después de que se creen los elementos
89+ setTimeout ( ( ) => {
90+ const totalWidth = carouselTrack . scrollWidth ;
91+ const moveDistance = totalWidth / 2 ;
92+
93+ let currentPosition = 0 ;
94+ const speed = 1 ; // píxeles por frame
95+
96+ function animate ( ) {
97+ currentPosition -= speed ;
98+
99+ // Cuando hemos movido exactamente la mitad, reiniciamos sin que se note
100+ if ( Math . abs ( currentPosition ) >= moveDistance ) {
101+ currentPosition = 0 ;
102+ }
103+
104+ carouselTrack . style . transform = `translateX(${ currentPosition } px)` ;
105+ requestAnimationFrame ( animate ) ;
106+ }
107+
108+ animate ( ) ;
109+ } , 100 ) ;
110+ } ) ;
58111 </ script >
59112</ section >
0 commit comments