MCPcopy
hub / github.com/react-dnd/react-dnd / HTML5BackendImpl

Class HTML5BackendImpl

packages/backend-html5/src/HTML5BackendImpl.ts:29–758  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27type RootNode = Node & { __isReactDndBackendSetUp: boolean | undefined }
28
29export class HTML5BackendImpl implements Backend {
30 private options: OptionsReader
31
32 // React-Dnd Components
33 private actions: DragDropActions
34 private monitor: DragDropMonitor
35 private registry: HandlerRegistry
36
37 // Internal State
38 private enterLeaveCounter: EnterLeaveCounter
39
40 private sourcePreviewNodes: Map<string, Element> = new Map()
41 private sourcePreviewNodeOptions: Map<string, any> = new Map()
42 private sourceNodes: Map<string, Element> = new Map()
43 private sourceNodeOptions: Map<string, any> = new Map()
44
45 private dragStartSourceIds: string[] | null = null
46 private dropTargetIds: string[] = []
47 private dragEnterTargetIds: string[] = []
48 private currentNativeSource: NativeDragSource | null = null
49 private currentNativeHandle: Identifier | null = null
50 private currentDragSourceNode: Element | null = null
51 private altKeyPressed = false
52 private mouseMoveTimeoutTimer: number | null = null
53 private asyncEndDragFrameId: number | null = null
54 private dragOverTargetIds: string[] | null = null
55
56 private lastClientOffset: XYCoord | null = null
57 private hoverRafId: number | null = null
58
59 public constructor(
60 manager: DragDropManager,
61 globalContext?: HTML5BackendContext,
62 options?: HTML5BackendOptions,
63 ) {
64 this.options = new OptionsReader(globalContext, options)
65 this.actions = manager.getActions()
66 this.monitor = manager.getMonitor()
67 this.registry = manager.getRegistry()
68 this.enterLeaveCounter = new EnterLeaveCounter(this.isNodeInDocument)
69 }
70
71 /**
72 * Generate profiling statistics for the HTML5Backend.
73 */
74 public profile(): Record<string, number> {
75 return {
76 sourcePreviewNodes: this.sourcePreviewNodes.size,
77 sourcePreviewNodeOptions: this.sourcePreviewNodeOptions.size,
78 sourceNodeOptions: this.sourceNodeOptions.size,
79 sourceNodes: this.sourceNodes.size,
80 dragStartSourceIds: this.dragStartSourceIds?.length || 0,
81 dropTargetIds: this.dropTargetIds.length,
82 dragEnterTargetIds: this.dragEnterTargetIds.length,
83 dragOverTargetIds: this.dragOverTargetIds?.length || 0,
84 }
85 }
86

Callers

nothing calls this directly

Calls 15

isDraggingNativeItemMethod · 0.95
beginDragNativeItemMethod · 0.95
getCurrentDropEffectMethod · 0.95
matchNativeItemTypeFunction · 0.85
getDragPreviewOffsetFunction · 0.85
getMethod · 0.80
publishDragSourceMethod · 0.80
loadDataTransferMethod · 0.80
enterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…