MCPcopy Create free account
hub / github.com/microsoft/SandDance / getPosition

Function getPosition

packages/sanddance-explorer/src/mouseEvent.ts:15–33  ·  view source on GitHub ↗
(e: MouseEvent | PointerEvent | TouchEvent)

Source from the content-addressed store, hash-verified

13}
14
15export function getPosition(e: MouseEvent | PointerEvent | TouchEvent): MousePosition {
16 const xy = hasClientXY(e as MouseEvent | PointerEvent);
17 if (xy) {
18 return xy;
19 }
20 const te = e as TouchEvent;
21 if (te?.touches) {
22 for (let i = 0; i < te.touches.length; i++) {
23 const xy = hasClientXY(te.touches[i]);
24 if (xy) {
25 return xy;
26 }
27 }
28 }
29 const el = e.target as HTMLElement;
30 if (el && el.getClientRects) {
31 return el.getClientRects()[0];
32 }
33}

Callers 1

updateViewerOptionsMethod · 0.90

Calls 1

hasClientXYFunction · 0.70

Tested by

no test coverage detected