触摸移动和触摸启动以及300ms延迟

touchmove and touchstart and the 300ms delay

本文关键字:触摸 300ms 延迟 启动 移动      更新时间:2023-09-26

我正在使用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'
  });
});

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

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

你可以尝试在你的bundle中添加fastclick polyfill, fastclick at github

那你就直接写

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