MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / getCenterPoint

Function getCenterPoint

entrypoints/utils/common.ts:40–56  ·  view source on GitHub ↗
(touches: TouchList, point: number)

Source from the content-addressed store, hash-verified

38
39// 获取触摸点的中心位置
40export 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
59export function findMatchingElement(element: Element, selector: string): Element | false {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected