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

Function startDragging

packages/react-aria/src/dnd/useDrag.ts:320–349  ·  view source on GitHub ↗
(target: HTMLElement)

Source from the content-addressed store, hash-verified

318 };
319
320 let startDragging = (target: HTMLElement) => {
321 if (typeof state.options.onDragStart === 'function') {
322 let rect = target.getBoundingClientRect();
323 state.options.onDragStart({
324 type: 'dragstart',
325 x: rect.x + rect.width / 2,
326 y: rect.y + rect.height / 2
327 });
328 }
329
330 DragManager.beginDragging(
331 {
332 element: target,
333 items: state.options.getItems(),
334 allowedDropOperations:
335 typeof state.options.getAllowedDropOperations === 'function'
336 ? state.options.getAllowedDropOperations()
337 : ['move', 'copy', 'link'],
338 onDragEnd(e) {
339 setDragging(null);
340 if (typeof state.options.onDragEnd === 'function') {
341 state.options.onDragEnd(e);
342 }
343 }
344 },
345 stringFormatter
346 );
347
348 setDragging(target);
349 };
350
351 let modality = useDragModality();
352 let message = !isDragging ? MESSAGES[modality].start : MESSAGES[modality].end;

Callers 4

onDragStartFunction · 0.70
onPressFunction · 0.70
onKeyUpCaptureFunction · 0.70
onClickFunction · 0.70

Calls 2

getItemsMethod · 0.80
setDraggingFunction · 0.70

Tested by

no test coverage detected