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

154
Views
How to increment the transform position faster and smoothly

I am changing translate value and incrementing it, but it seems that the value is incrementing like : - 0, -5, -10, -15, -20 because I have multiplied the difference of the mouse moved and the actual mouse position, so my question is, how can I make the speed of increment faster without multiplying it, like 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15?

Here is the example code: https://jsfiddle.net/dy1vk40f/1/

scrollcontainer.addEventListener('mousemove', (e) => {
  if (!isDown) return;
  e.preventDefault();

  const x = e.pageX;
  const style = window.getComputedStyle(scrollcontainer);
  const matrix = new WebKitCSSMatrix(style.transform);

  const walk = x - startX; // startX MEANS THE POSITION MOUSE IS CLICKED for dragging
  scrollcontainer.style.userSelect = 'none';
  scrollcontainer.style.transform = `translate3d(${matrix.m41 + (walk * 5)}px, 0px, 0px)`;
  startX = e.pageX;

});

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!