MCPcopy Create free account
hub / github.com/adobe/react-spectrum / onPointerDown

Function onPointerDown

packages/react-aria/src/dnd/useDrag.ts:366–389  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

364 interactions = {
365 ...descriptionProps,
366 onPointerDown(e) {
367 modalityOnPointerDown.current = isVirtualPointerEvent(e.nativeEvent)
368 ? 'virtual'
369 : e.pointerType;
370
371 // Try to detect virtual drag passthrough gestures.
372 if (e.width < 1 && e.height < 1 && isIOS() && isWebKit()) {
373 // iOS VoiceOver.
374 modalityOnPointerDown.current = 'virtual';
375 } else {
376 let rect = e.currentTarget.getBoundingClientRect();
377 let offsetX = e.clientX - rect.x;
378 let offsetY = e.clientY - rect.y;
379 let centerX = rect.width / 2;
380 let centerY = rect.height / 2;
381
382 if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) {
383 // Android TalkBack.
384 modalityOnPointerDown.current = 'virtual';
385 } else {
386 modalityOnPointerDown.current = e.pointerType;
387 }
388 }
389 },
390 onKeyDownCapture(e) {
391 if (getEventTarget(e) === e.currentTarget && e.key === 'Enter') {
392 e.preventDefault();

Callers

nothing calls this directly

Calls 1

isVirtualPointerEventFunction · 0.90

Tested by

no test coverage detected