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

206
Visualizações
Stop horizontal scroll based animation in the middle of the page

I found this snippet online, and I'm looking to alter it slightly.

const scrollText = document.querySelector(".scroll-text");

    window.addEventListener("scroll", () => {
      scrollText.style.left = `${1000 - 1.5 * scrollY}px`;

    });

Right now, I have a heading rolling in from the right side of the screen towards the left side, and it's working smoothly.

What I'd ideally want though, is for the text to stop dead center in the middle of the screen, when the user as scrolled too a certain point down the page.

Could someone kindly tell me how I'd go about implementing something like this?

Here's my HTML and CSS as well for good measure.

HTML:

<div class="test">
    <div class="main wrapper">
      <h1 class="scroll-text">I'm going too far!</h1>
    </div>
  </div>

CSS:

.test {
  background: #ffffff;
  color: #000000;
  overflow-x: hidden;
}

.wrapper {
  position: relative;
  width: 1150px;
  min-height: 50vh;
  margin: 0 auto;
}

.main {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.main .scroll-text {
  position: relative;
  font-size: 5rem;
  white-space: nowrap;
  scroll-snap-align: center;
}
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