Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

317
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!