MCPcopy Create free account
hub / github.com/react-dnd/react-dnd / isOverTarget

Method isOverTarget

packages/dnd-core/src/DragDropMonitor.js:112–135  ·  view source on GitHub ↗
(targetId, options = { shallow: false })

Source from the content-addressed store, hash-verified

110 }
111
112 isOverTarget(targetId, options = { shallow: false }) {
113 const { shallow } = options;
114 if (!this.isDragging()) {
115 return false;
116 }
117
118 const targetType = this.registry.getTargetType(targetId);
119 const draggedItemType = this.getItemType();
120 if (!matchesType(targetType, draggedItemType)) {
121 return false;
122 }
123
124 const targetIds = this.getTargetIds();
125 if (!targetIds.length) {
126 return false;
127 }
128
129 const index = targetIds.indexOf(targetId);
130 if (shallow) {
131 return index === targetIds.length - 1;
132 } else {
133 return index > -1;
134 }
135 }
136
137 getItemType() {
138 return this.store.getState().dragOperation.itemType;

Callers 2

isOverMethod · 0.80

Calls 5

isDraggingMethod · 0.95
getItemTypeMethod · 0.95
getTargetIdsMethod · 0.95
matchesTypeFunction · 0.85
getTargetTypeMethod · 0.80

Tested by

no test coverage detected