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

Class TargetMonitor

packages/react-dnd/src/createTargetMonitor.js:5–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3let isCallingCanDrop = false;
4
5class TargetMonitor {
6 constructor(manager) {
7 this.internalMonitor = manager.getMonitor();
8 }
9
10 receiveHandlerId(targetId) {
11 this.targetId = targetId;
12 }
13
14 canDrop() {
15 invariant(
16 !isCallingCanDrop,
17 'You may not call monitor.canDrop() inside your canDrop() implementation. ' +
18 'Read more: http://react-dnd.github.io/react-dnd/docs-drop-target-monitor.html',
19 );
20
21 try {
22 isCallingCanDrop = true;
23 return this.internalMonitor.canDropOnTarget(this.targetId);
24 } finally {
25 isCallingCanDrop = false;
26 }
27 }
28
29 isOver(options) {
30 return this.internalMonitor.isOverTarget(this.targetId, options);
31 }
32
33 getItemType() {
34 return this.internalMonitor.getItemType();
35 }
36
37 getItem() {
38 return this.internalMonitor.getItem();
39 }
40
41 getDropResult() {
42 return this.internalMonitor.getDropResult();
43 }
44
45 didDrop() {
46 return this.internalMonitor.didDrop();
47 }
48
49 getInitialClientOffset() {
50 return this.internalMonitor.getInitialClientOffset();
51 }
52
53 getInitialSourceClientOffset() {
54 return this.internalMonitor.getInitialSourceClientOffset();
55 }
56
57 getSourceClientOffset() {
58 return this.internalMonitor.getSourceClientOffset();
59 }
60
61 getClientOffset() {
62 return this.internalMonitor.getClientOffset();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected