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

163
Views
moving text with scroll

So I'm trying to convert some guys tutorial from an animation that moves when the mouse moves to moving when scrolling down. it is moving now but only when I move both my mouse and scroll at the same time.

I am looking for a method that moves the words when just scrolling

<section id="bbbb">
<div class="text">
<h2 style="--i:0.5"><span> because boring is bad for business</span>
</h2></div> 
</section>

const position = document.documentElement;
position.addEventListener('mousewheel', e => {
position.style.setProperty('--x', e.clientX + 'px')

})

.text h2 {
  position: relative;
  width: 100%;
  font-size: 6.5em;
  color: rgb(255, 255, 255);
  line-height: 1em;
  white-space: nowrap;
  text-shadow: calc(var(--x)) 100px 0 rgba(255, 255,255,0.2);
  transform: translateX(calc(0% - var(--x)*var(--i)));
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

your javascript will be like this

const element = document.querySelector("#container");

element.addEventListener('wheel', (event) => {
  event.preventDefault();

  element.scrollBy({
    left: event.deltaY < 0 ? -30 : 30,
    
  });
});
#container {
  display: flex;
  overflow-x: scroll;
  overflow-y:hidden;
  max-width: 50rem;
  margin: 0 auto;
}

.text h2 {
  position: relative;
  width: 100%;
  font-size: 6.5em;
  color: black;
  line-height: 1em;
  white-space: nowrap;
  text-shadow: calc(var(--x)) 100px 0 rgba(255, 255,255,0.2);
  transform: translateX(calc(0% - var(--x)*var(--i)));
}
<div id="container">
  <section id="bbbb">
    <div class="text">
      <h2 style="--i:0.5"><span> because boring is bad for business</span>
    </h2></div> 
  </section>
</div>

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