我一直在搞乱 IE10 触摸 API(在三星 Slate 上测试),我发现在按住触摸后触发了触摸释放操作。
因此,当我将手指放在屏幕上时,以下是触发事件的过程:
- 0ms = MSPointerDown,pointerId = 0
- 1ms = MSPointerMove,pointerId = 0
- ~1000ms = MSPointerUp with pointerId = 0
- ~1001ms = MSPointerDown with pointerId = 1 REPEAT POINT
- ~1002ms = MSPointerMove with pointerId = 1
- ~1250ms = MSPointerUp,pointerId = 1
然后在 REPEAT POINT 重复增加pointerId。
这是代码:
// Setup the css on the canvas (allows for detection of MSPointerMove)
$(canvas).css("-ms-touch-action", "none");
// Initialize regular touch actions
canvas.addEventListener('MSPointerDown', TouchStart, false);
canvas.addEventListener('MSPointerMove', TouchMove, false);
canvas.addEventListener('MSPointerUp', TouchEnd, false);
// Initialize the revoking of gestures/other unwanted pieces
canvas.addEventListener("MSPointerCancel", function (e) { e.preventDefault(); }, false);
canvas.addEventListener("MSGestureInit", function (e) { if (e.preventManipulation) e.preventManipulation(); }, false);
canvas.addEventListener("MSHoldVisual", function (e) { e.preventDefault(); }, false);
这绝对可能只是一个 Slate 问题,但我认为要求确保我没有遗漏任何东西是明智的。如果这不仅仅是一个 Slate 问题,那么我如何允许用户按住手指而不在大约一秒钟后触发不需要的“MSPointerUp”事件。