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

120
Views
¿Cómo mover suavemente un objeto en una pantalla táctil?

El problema es que mi código funciona para navegadores de computadora, pero no funciona para navegadores móviles. Mi tarea es sostener mi dedo sobre un objeto, comenzar a mover mi dedo por la pantalla táctil y ver el movimiento suave del objeto en la pantalla, y cuando suelto mi dedo, puedo mover algunos objetos más, y no el mismo . Todos los eventos deben tener lugar en navegadores móviles. Traté de usar eventos como touchmove, touchstart, pero no funcionan en absoluto, ya que están diseñados para funcionar con pantallas táctiles.

 <!DOCTYPE html> <html> <head> <title>LogicBuilder</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style> *{ position: absolute; } #ball{ width:100px; height:100px; border-radius: 50%; background-color: blue; text-align: center; position:absolute; left:300px; top:300px; } </style> </head> <body> <div id="ball"></div> </body> <script> ball.addEventListener('mousemove', function(event) { // (1) отследить нажатие moveAt(event.pageX, event.pageY); function moveAt(pageX, pageY) { ball.style.left = pageX - ball.offsetWidth / 2 + 'px'; ball.style.top = pageY - ball.offsetHeight / 2 + 'px'; } function onMouseMove(event) { moveAt(event.pageX, event.pageY); } document.addEventListener('touchmove', onMouseMove); document.onmouseup = function() { document.removeEventListener('mousemove', onMouseMove); ball.onmouseup = null; }; }); </script> </html>

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!