touchmove和touchstart以及300ms延迟

时间:2021-10-12 23:44:28

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

我正在使用phonegap将web应用程序转换为android,我正在使用它来控制游标

$(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.

现在问题是,当我触摸屏幕时,光标不会出现,直到我开始移动我的手指,这是因为我使用touchmove所以我使用touchstart而结果是当我触摸屏幕时光标出现但不是移动。

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

是否有一个解决方案,我可以毫无延迟地找到光标,触摸屏幕后移动它完美?

1 个解决方案

#1


0  

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

你可以尝试在你的包中添加fastclick polyfill,快速点击github

then you just do

那你就做

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

or with jquery...

或者用jquery ......

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

#1


0  

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

你可以尝试在你的包中添加fastclick polyfill,快速点击github

then you just do

那你就做

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

or with jquery...

或者用jquery ......

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