* get the center of all the pointers * @param {Array} pointers * @return {Object} center contains `x` and `y` properties
(pointers)
| 92976 | * @param {Array} pointers |
| 92977 | * @return {Object} center contains `x` and `y` properties |
| 92978 | */ function getCenter(pointers) { |
| 92979 | var pointersLength = pointers.length; |
| 92980 | // no need to loop when only one touch |
| 92981 | if (pointersLength === 1) return { |
| 92982 | x: round(pointers[0].clientX), |
| 92983 | y: round(pointers[0].clientY) |
| 92984 | }; |
| 92985 | var x = 0, y = 0, i = 0; |
| 92986 | while(i < pointersLength){ |
| 92987 | x += pointers[i].clientX; |
| 92988 | y += pointers[i].clientY; |
| 92989 | i++; |
| 92990 | } |
| 92991 | return { |
| 92992 | x: round(x / pointersLength), |
| 92993 | y: round(y / pointersLength) |
| 92994 | }; |
| 92995 | } |
| 92996 | /** |
| 92997 | * calculate the velocity between two points. unit is in px per ms. |
| 92998 | * @param {Number} deltaTime |
no test coverage detected