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

325
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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