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

106
Views
Scroll trigger multi use

I'm trying to provide a flex element animation that I can use multiple times. I can't use it multiple times because it triggers when the page is scrolling. How can I convert the closest element to a structure that I can select? My goal is to scroll the elements at different speeds with the transform feature while the page is scrolling.

$(window).scroll(function () {
    let dataDiv = $(".relaxable");
    let dataRl = parseInt(dataDiv.attr("dataRelaxing"));

    
    let scroll = parseInt($(window).scrollTop());
    let wHeight = parseInt($(window).height());
    let transformCalc = (scroll * 0.1) + ((wHeight/100) + dataRl);

    

    console.log(transformCalc);

});
body {
height:2500px;
}
.relaxable {
background:red;
width:30px;
height:30px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="relaxable" dataRelaxing="10" id="one">
</div>
<div class="relaxable" dataRelaxing="20" id="two">
</div>

In the above example I can get the values of the first div element.I can't take the value "20" in the second div element and act accordingly

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!