@@ -305,6 +305,11 @@ function clampIndex(i, len) {
305305 return ( i + len ) % len ;
306306}
307307
308+ function getProjectsList ( ) {
309+ const proj = STATE . dict ?. projects ;
310+ return proj ? getProjectItems ( proj ) : [ ] ;
311+ }
312+
308313function renderProjects ( ) {
309314 const stage = document . getElementById ( "project-stage" ) ;
310315 const dots = document . getElementById ( "project-dots" ) ;
@@ -322,8 +327,8 @@ function renderProjects(){
322327 const LP = labels . problem ?? ( STATE . lang === "es" ? "Problema" : "Problem" ) ;
323328 const LS = labels . solution ?? ( STATE . lang === "es" ? "Solución" : "Solution" ) ;
324329 const LR = labels . result ?? ( STATE . lang === "es" ? "Resultado" : "Result" ) ;
325-
326- const items = getProjectItems ( proj ) ; // 👈 importante, ver B)
330+
331+ const items = getProjectsList ( ) ;
327332 if ( ! items . length ) {
328333 stage . innerHTML = "" ;
329334 dots . innerHTML = "" ;
@@ -352,12 +357,6 @@ function renderProjects(){
352357 ${ ( p . tech || [ ] ) . map ( t => `<span class="${ t . cls || "" } ">${ t . label } </span>` ) . join ( "" ) }
353358 </div>
354359
355- <div class="project-psr">
356- <div><strong>${ L . problem } :</strong> ${ p . problem || "—" } </div>
357- <div><strong>${ L . solution } :</strong> ${ p . solution || "—" } </div>
358- <div><strong>${ L . result } :</strong> ${ p . result || "—" } </div>
359- </div>
360-
361360 <details>
362361 <summary>+ info</summary>
363362 <p>${ p . why || "" } </p>
@@ -388,44 +387,41 @@ function setupProjectsCarousel() {
388387 if ( ! prev || ! next || ! stage ) return ;
389388
390389 prev . addEventListener ( "click" , ( ) => {
391- const items = getProjectItems ( ) ;
390+ const items = getProjectsList ( ) ;
391+ if ( ! items . length ) return ;
392392 PROJECT_INDEX = clampIndex ( PROJECT_INDEX - 1 , items . length ) ;
393393 renderProjects ( ) ;
394394 } ) ;
395395
396396 next . addEventListener ( "click" , ( ) => {
397- const items = getProjectItems ( ) ;
397+ const items = getProjectsList ( ) ;
398+ if ( ! items . length ) return ;
398399 PROJECT_INDEX = clampIndex ( PROJECT_INDEX + 1 , items . length ) ;
399400 renderProjects ( ) ;
400401 } ) ;
401402
402403 let x0 = null ;
403- stage . addEventListener (
404- "touchstart" ,
405- ( e ) => {
406- x0 = e . touches ?. [ 0 ] ?. clientX ?? null ;
407- } ,
408- { passive : true }
409- ) ;
404+ stage . addEventListener ( "touchstart" , ( e ) => {
405+ x0 = e . touches ?. [ 0 ] ?. clientX ?? null ;
406+ } , { passive : true } ) ;
410407
411- stage . addEventListener (
412- "touchend" ,
413- ( e ) => {
414- const x1 = e . changedTouches ?. [ 0 ] ?. clientX ?? null ;
415- if ( x0 == null || x1 == null ) return ;
408+ stage . addEventListener ( "touchend" , ( e ) => {
409+ const x1 = e . changedTouches ?. [ 0 ] ?. clientX ?? null ;
410+ if ( x0 == null || x1 == null ) return ;
416411
417- const dx = x1 - x0 ;
418- if ( Math . abs ( dx ) < 60 ) return ;
412+ const dx = x1 - x0 ;
413+ if ( Math . abs ( dx ) < 60 ) return ;
419414
420- const items = getProjectItems ( ) ;
421- PROJECT_INDEX = clampIndex ( PROJECT_INDEX + ( dx < 0 ? 1 : - 1 ) , items . length ) ;
422- renderProjects ( ) ;
423- x0 = null ;
424- } ,
425- { passive : true }
426- ) ;
415+ const items = getProjectsList ( ) ;
416+ if ( ! items . length ) return ;
417+
418+ PROJECT_INDEX = clampIndex ( PROJECT_INDEX + ( dx < 0 ? 1 : - 1 ) , items . length ) ;
419+ renderProjects ( ) ;
420+ x0 = null ;
421+ } , { passive : true } ) ;
427422}
428423
424+
429425/* =========================================================
430426 CONTACT FORM -> Gmail draft
431427 ========================================================= */
0 commit comments