简体   繁体   中英

touchmove and touchstart and the 300ms delay

i am converting a web app to android using phonegap and i am using this to control a cursor

$(document).on('touchmove', function (e) {


  var touch = e.originalEvent.touches["0"];



  $img.css({
    top: (touch.clientY)  - 105,
    left:  (touch.clientX) - 25,
    display: 'block'
  });

});

now the problem is when i touch the screen the cursor doesn't appear until i start moving my fingers and that is because i am using touchmove so i used instead touchstart and the result was when i touch the screen the cursor appears but doesn't move.

is there a solution where i can find the cursor without any delay and after touching the screen and move it perfectly ??

you can try adding fastclick polyfill to your bundle, fastclick at github

then you just do

if ('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
    FastClick.attach(document.body);
}, false);}

or with jquery...

$(function() {
FastClick.attach(document.body);});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM