Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
Svelte can't find .ScrollTop of a variable

Hello I have an element which is being referenced to the script like this

<div bind:this={AboutMeAnimation} />

and then In my script I console log ScrollTop value

    let AboutMeAnimation;
    console.log(AboutMeAnimation.ScrollTop);

and for some resson I'm getting an error can some one tell me why?enter image description here

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

A couple of issues, the first is that is scrollTop with a lowercase “s”, the other is that the element does not bind immediately so if you are putting this statement at the top level of the component it will be undefined for some period of time. You can use onMount or similar to get this value:

onMount(() => {
  console.log(AboutMeAnimation.scrollTop);
});

Otherwise a reactive statement could work also:

$: {
  console.log(AboutMeAnimation && AboutMeAnimation.scrollTop);
}

Hopefully that helps!

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda