(touches: TouchList, point: number)
| 38 | |
| 39 | // 获取触摸点的中心位置 |
| 40 | export function getCenterPoint(touches: TouchList, point: number): { x: number, y: number } | undefined { |
| 41 | // 检查触摸点数量是否等于指定的数量 |
| 42 | if (touches.length !== point) return; |
| 43 | |
| 44 | let centerX = 0; |
| 45 | let centerY = 0; |
| 46 | // 累加所有触摸点的坐标 |
| 47 | for (let i = 0; i < touches.length; i++) { |
| 48 | centerX += touches[i].clientX; |
| 49 | centerY += touches[i].clientY; |
| 50 | } |
| 51 | // 计算中心点坐标 |
| 52 | centerX /= touches.length; |
| 53 | centerY /= touches.length; |
| 54 | |
| 55 | return {x: centerX, y: centerY}; |
| 56 | } |
| 57 | |
| 58 | // 按 selector 查找匹配的元素,返回匹配的元素或 false |
| 59 | export function findMatchingElement(element: Element, selector: string): Element | false { |
no outgoing calls
no test coverage detected