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

Function startDragging

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

Source from the content-addressed store, hash-verified

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