Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda