📜  触摸保持事件 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:05.433000             🧑  作者: Mango

代码示例1
var onlongtouch; 
var timer;
var touchduration = 500; //length of time we want the user to touch before we do something

touchstart() {
    timer = setTimeout(onlongtouch, touchduration); 
}

touchend() {

    //stops short touches from firing the event
    if (timer)
        clearTimeout(timer); // clearTimeout, not cleartimeout..
}

onlongtouch = function() { //do something };