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

Function onDragEnter

packages/react-aria/src/dnd/useDrop.ts:235–278  ·  view source on GitHub ↗
(e: DragEvent)

Source from the content-addressed store, hash-verified

233 };
234
235 let onDragEnter = (e: DragEvent) => {
236 e.preventDefault();
237 e.stopPropagation();
238 state.dragOverElements.add(getEventTarget(e));
239 if (state.dragOverElements.size > 1) {
240 return;
241 }
242
243 let allowedOperationsBits = getAllowedOperations(e);
244 let allowedOperations = allowedOperationsToArray(allowedOperationsBits);
245 let dropOperation = allowedOperations[0];
246
247 if (typeof options.getDropOperation === 'function') {
248 let types = new DragTypes(e.dataTransfer);
249 dropOperation = getDropOperation(
250 allowedOperationsBits,
251 options.getDropOperation(types, allowedOperations)
252 );
253 }
254
255 if (typeof options.getDropOperationForPoint === 'function') {
256 let types = new DragTypes(e.dataTransfer);
257 let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
258 dropOperation = getDropOperation(
259 allowedOperationsBits,
260 options.getDropOperationForPoint(
261 types,
262 allowedOperations,
263 e.clientX - rect.x,
264 e.clientY - rect.y
265 )
266 );
267 }
268
269 state.x = e.clientX;
270 state.y = e.clientY;
271 state.allowedOperations = allowedOperationsBits;
272 state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';
273 e.dataTransfer.dropEffect = state.dropEffect;
274
275 if (dropOperation !== 'cancel') {
276 fireDropEnter(e);
277 }
278 };
279
280 let onDragLeave = (e: DragEvent) => {
281 e.preventDefault();

Callers

nothing calls this directly

Calls 7

getEventTargetFunction · 0.90
getAllowedOperationsFunction · 0.85
allowedOperationsToArrayFunction · 0.85
fireDropEnterFunction · 0.85
getDropOperationMethod · 0.80
getDropOperationFunction · 0.70
addMethod · 0.65

Tested by

no test coverage detected