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

322
Views
setTimeout to scrollIntoView in svelte

How would i run a bucle to scrollIntoView() in svelte with setTimeout().

I am trying to do an autoSlide.

const scrollIntoView = ({currentTarget}) => {
    const scrollToElement = document.querySelector(
        currentTarget.getAttribute('href')
    )

    if (!scrollToElement) return

    scrollToElement.scrollIntoView({
        behavior: 'smooth',
    })
}

it is controlled by nav with on:click="{scrollIntoView}"

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Add the preventDefault modifier:

<a href="#some_id" on:click|preventDefault={scrollIntoView}>...

In your current implementation the default is not prevented. (and by default the browser jumps to the targeted element instantly)

(Not sure what "run a bucle" means or why you'd want a setTimeout)

about 4 years ago · Juan Pablo Isaza Report
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!