MCPcopy
hub / github.com/adobe/react-spectrum / mapModality

Function mapModality

packages/react-aria/src/dnd/utils.ts:68–87  ·  view source on GitHub ↗
(modality: string | null)

Source from the content-addressed store, hash-verified

66}
67
68function mapModality(modality: string | null) {
69 if (!modality) {
70 modality = 'virtual';
71 }
72
73 if (modality === 'pointer') {
74 modality = 'virtual';
75 }
76
77 if (
78 modality === 'virtual' &&
79 typeof window !== 'undefined' &&
80 typeof window.matchMedia === 'function' &&
81 window.matchMedia('(pointer: coarse)').matches
82 ) {
83 modality = 'touch';
84 }
85
86 return modality;
87}
88
89export function useDragModality(): string {
90 return mapModality(useInteractionModality());

Callers 2

useDragModalityFunction · 0.85
getDragModalityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected