* @function Events.prototype.handleBrowserEvent * @description 对 triggerEvent 函数的包装,给事件对象设置了 xy 属性(即当前鼠标点的 xy 坐标)。 * @param {Event} evt - 事件对象。
(evt)
| 399 | * @param {Event} evt - 事件对象。 |
| 400 | */ |
| 401 | handleBrowserEvent(evt) { |
| 402 | var type = evt.type, listeners = this.listeners[type]; |
| 403 | if (!listeners || listeners.length == 0) { |
| 404 | // noone's listening, bail out |
| 405 | return; |
| 406 | } |
| 407 | // add clientX & clientY to all events - corresponds to average x, y |
| 408 | var touches = evt.touches; |
| 409 | if (touches && touches[0]) { |
| 410 | var x = 0; |
| 411 | var y = 0; |
| 412 | var num = touches.length; |
| 413 | var touch; |
| 414 | for (var i = 0; i < num; ++i) { |
| 415 | touch = touches[i]; |
| 416 | x += touch.clientX; |
| 417 | y += touch.clientY; |
| 418 | } |
| 419 | evt.clientX = x / num; |
| 420 | evt.clientY = y / num; |
| 421 | } |
| 422 | if (this.includeXY) { |
| 423 | evt.xy = this.getMousePosition(evt); |
| 424 | } |
| 425 | this.triggerEvent(type, evt); |
| 426 | } |
| 427 | |
| 428 | |
| 429 | /** |
nothing calls this directly
no test coverage detected