Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript中区分触摸和交换事件_Javascript_Jquery_Iphone_Uiwebview - Fatal编程技术网

Javascript中区分触摸和交换事件

Javascript中区分触摸和交换事件,javascript,jquery,iphone,uiwebview,Javascript,Jquery,Iphone,Uiwebview,我有一个用于交换图像的图像库。在gallery中,我使用了touchstart、touchmove、touchend和touchcancel事件。但现在我也需要处理触摸事件。那么,我应该在移动设备上分别区分触摸和交换事件吗?我正在使用以下技巧: $("#some_element") .on('touchstart', function(e) { touch_y = e.changedTouches[event.changedTouches.length -

我有一个用于交换图像的图像库。在gallery中,我使用了touchstart、touchmove、touchend和touchcancel事件。但现在我也需要处理触摸事件。那么,我应该在移动设备上分别区分触摸和交换事件吗?

我正在使用以下技巧:

$("#some_element")
        .on('touchstart', function(e) {
            touch_y = e.changedTouches[event.changedTouches.length - 1].clientY;
            touch_x = e.changedTouches[event.changedTouches.length - 1].clientX;
        })
        .on("click touchend", function (e) {
            if(e.type=='touchend' && (Math.abs(touch_y-e.changedTouches[event.changedTouches.length - 1].clientY)>3 || Math.abs(touch_x-e.changedTouches[event.changedTouches.length - 1].clientX)>3)) return;
            // Your code here
            alert('This element only touched, not swiped');
        });

用户960567,你能检查一下你的问题吗。这不完全有道理。@beetrootbeetroot,为什么?交换图像和单击图像是不同的事情