VSO*_*VSO 12 javascript touch angularjs jqlite
编辑:"这不能在Angular UI Modals中完成"是一个有效的答案,如果实际情况如此.
这是我从触摸事件中获得的返回数据.显然缺少任何有用的触摸X/Y坐标(https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/changedTouches).这是一个毫无希望的通用问题,但是,任何想法?传递给触摸时执行的函数的"event"对象:
{
"originalEvent": {
"isTrusted": true
},
"type": "touchstart",
"timeStamp": 1450388006795,
"jQuery203026962137850932777": true,
"which": 0,
"view": "$WINDOW",
"target": {},
"shiftKey": false,
"metaKey": false,
"eventPhase": 3,
"currentTarget": {},
"ctrlKey": false,
"cancelable": true,
"bubbles": true,
"altKey": false,
"delegateTarget": {},
"handleObj": {
"type": "touchstart",
"origType": "touchstart",
"data": null,
"guid": 2026,
"namespace": ""
},
"data": null
}
Run Code Online (Sandbox Code Playgroud)
现在,这是在画布中的角度UI模式,但鼠标事件工作正常.这是我的元素btw:
link: function(scope, element, attrs, model){
//scope.canvasElem = element[0].children[0].children[0];
scope.canvasElem = angular.element($('.touchScreen'))[0];
scope.ctx = scope.canvasElem.getContext('2d');
Run Code Online (Sandbox Code Playgroud)
这是我如何绑定的一个例子:
element.bind('touchstart', scope.touchStart);
Run Code Online (Sandbox Code Playgroud)
编辑,这是一个用于比较的mousedown事件对象:
{
"originalEvent": {
"isTrusted": true
},
"type": "mousedown",
"timeStamp": 1450389131400,
"jQuery20309114612976554781": true,
"toElement": {},
"screenY": 436,
"screenX": 726,
"pageY": 375,
"pageX": 726,
"offsetY": 81,
"offsetX": 41,
"clientY": 375,
"clientX": 726,
"buttons": 1,
"button": 0,
"which": 1,
"view": "$WINDOW",
"target": {},
"shiftKey": false,
"relatedTarget": null,
"metaKey": false,
"eventPhase": 3,
"currentTarget": {},
"ctrlKey": false,
"cancelable": true,
"bubbles": true,
"altKey": false,
"delegateTarget": {},
"handleObj": {
"type": "mousedown",
"origType": "mousedown",
"data": null,
"guid": 2025,
"namespace": ""
},
"data": null
}
Run Code Online (Sandbox Code Playgroud)
要获取 x 和 y 坐标,请尝试使用以下代码
x1 = event.touches[0].pageX;
y1 = event.touches[0].pageY;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1353 次 |
| 最近记录: |