Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!