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

210
Vistas
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 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