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

190
Visualizações
Scroll element in js if user is not scrolling up

I'm trying to make some sort of console in my vue app. I already managed to scroll down when new elements get added to the ui console (just a element with a list of entries) by using:

watch: {
  uilogs: {
    handler: function() {
      // if last not in view and no focus on scrollbar detected, continue:
      this.$nextTick(() => {
        Array.from(document.querySelectorAll('#uiconsole > div'))
             .pop()
             .scrollIntoView();
      })
    }
  }   
}

I need the watcher because vue has to update the ui after adding a new element to the list before scrolling to that last element. Otherwise it would not be in the ui and I would not be able to scroll to it.

The problem

I dont want it to scroll if user uses the scrollbar to scroll up (to check some of the console entries above). I do not know how to achieve that. I already tried detecting if the scrollbar is at bottom, if it isn't at bottom => I wouldnt scroll to the last element. But I did not manage to do that.

Any ideas? Here's my app: https://gitlab.com/omeldar/advent-of-code

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