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

251
Visualizações
Keep scroll at bottom on safari with vue

I'm making a chatroom-like website using vue.

I use display: flex & column-reverse on css to reverse messages view.
And use Array unshift to insert new message.

On chrome & firefox, this will always keep the newest message(at bottom) in view.
But safari don't.

I tried method "scrollTo" after new message append, but it seems not working without user interact.
(New message may append without any user interact in a short time before)

I also tried detect whether bottom or not using "scrollTop" (then I can notice user a new message came in) but failed on safari too.

Any other way to make safari work the same as chrome/firefox do?

A demo here, can open with safari with the problem.

CodePen

<!-- Use preprocessors via the lang attribute! e.g. <template lang="pug"> -->
<template>
  <div id="app" ref="app">
    <p 
      v-for="message in messages"
    >
      {{ message }}
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      messages: []
    };
  },
  mounted() {
    setInterval(() => {
      this.messages.unshift((new Date()).toString())
      this.$nextTick(() => {
        this.$refs.app.scrollTo(0, 0)
      })
    }, 1000)
  }
};
</script>

<!-- Use preprocessors via the lang attribute! e.g. <style lang="scss"> -->
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  text-align: center;
  color: #2c3e50;
  display: flex;
  flex-direction: column-reverse;
  overflow-y: scroll;
  scroll-behavior: smooth;
  height: 90vh;
}

a,
button {
  color: #4fc08d;
}

button {
  background: none;
  border: solid 1px;
  border-radius: 2em;
  font: inherit;
  padding: 0.75em 2em;
}
</style>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Changing your overflow from scroll to visible should solve this issue.

#app {
  overflow: visible;
}

The reason why it's not scrolling is your #app container does not pick up the content height changed inside the app box,

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