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

140
Visualizações
Drag position issue with event touch move on touch screen

I have implemented drag and drop with html/JavaScript. It works well with mouse drag but having issue with touch screen. while dragging item on touch screen it's position is not correct either it goes up or down from the touch point. Thanks in advance!

var _left = _touch.clientX;
var _top = _touch.clientY;
_touch.target.style.left = _left + 'px';
_touch.target.style.top = _top + 'px';
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue has been resolved. The fix is as below:

var droppable = document.elementFromPoint(_touch.clientX, _touch.clientY);
var _left = _touch.clientX - droppable.getBoundingClientRect().left;
var _top = _touch.clientY - droppable.getBoundingClientRect().top;
_touch.target.style.left = _left + 'px';
_touch.target.style.top = _top + 'px';

I am getting the droppable container's left and top and subtracting it from draggable item.

about 4 years ago · Juan Pablo Isaza Relatório
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