Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

311
Vistas
My js scroll animation is not working, i see a lot of ',' expected ts (1005) and (type annotations can only be used in typescript files)

I'm following a tutorial and I'm near the end, my scrolling animation doesn't seem to work? could anyone point out if I have any mistakes with my javascript as I'm fairly new?

https://www.youtube.com/watch?v=afaqr875gUE&t=486s (in case you were wondering what the tutorial was)

code:

document.lastScrollPosition = 0;
document.lastCentered = 0;
document.onWayTo = null;

document.addEventListener('scroll', listener: () => {
  const direction = window.pageYOffset - document.lastScrollPosition > 0 'down' : 'up';
  const sections = [...document.querySelectorAll('selection')];

  if(document.onWayTo === null) {
    const destIndex = direction === 'up' ? document.lastCentered - 1 : document.lastCentered + 1;
    if(destIndex >= 0 && destIndex < sections.length) {
      console.log({destIndex,direction});
     document.onWayTo = destIndex;
      window.scroll(x: 0, sections[destIndex].offsetTop);
    }
  }
  


  sections.forEach((section,index : number) => {
    if(window.pageYOffset === section.offsetTop) {
      document.lastCentered = index;
      section.className = 'action';
      if (document.onWayTo === index) {
        document.onWayTo = null;
      }

    } else{
      section.className = '';
    }

  })



  document.lastScrollPosition = window.pageYOffset;

})
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda