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

Class TouchBackendImpl

packages/backend-touch/src/TouchBackendImpl.ts:45–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45export class TouchBackendImpl implements Backend {
46 private options: OptionsReader
47
48 // React-DnD Dependencies
49 private actions: DragDropActions
50 private monitor: DragDropMonitor
51
52 // Internal State
53 private static isSetUp: boolean
54 public sourceNodes: Map<Identifier, HTMLElement>
55 public sourcePreviewNodes: Map<string, HTMLElement>
56 public sourcePreviewNodeOptions: Map<string, any>
57 public targetNodes: Map<string, HTMLElement>
58 private _mouseClientOffset: Partial<XYCoord>
59 private _isScrolling: boolean
60 private listenerTypes: ListenerType[]
61 private moveStartSourceIds: string[] | undefined
62 private waitingForDelay: boolean | undefined
63 private timeout: ReturnType<typeof setTimeout> | undefined
64 private dragOverTargetIds: string[] | undefined
65 private draggedSourceNode: HTMLElement | undefined
66 private draggedSourceNodeRemovalObserver: MutationObserver | undefined
67
68 // Patch for iOS 13, discussion over #1585
69 private lastTargetTouchFallback: Touch | undefined
70
71 public constructor(
72 manager: DragDropManager,
73 context: TouchBackendContext,
74 options: Partial<TouchBackendOptions>,
75 ) {
76 this.options = new OptionsReader(options, context)
77 this.actions = manager.getActions()
78 this.monitor = manager.getMonitor()
79
80 this.sourceNodes = new Map()
81 this.sourcePreviewNodes = new Map()
82 this.sourcePreviewNodeOptions = new Map()
83 this.targetNodes = new Map()
84 this.listenerTypes = []
85 this._mouseClientOffset = {}
86 this._isScrolling = false
87
88 if (this.options.enableMouseEvents) {
89 this.listenerTypes.push(ListenerType.mouse)
90 }
91
92 if (this.options.enableTouchEvents) {
93 this.listenerTypes.push(ListenerType.touch)
94 }
95
96 if (this.options.enableKeyboardEvents) {
97 this.listenerTypes.push(ListenerType.keyboard)
98 }
99 }
100
101 /**
102 * Generate profiling statistics for the HTML5Backend.

Callers

nothing calls this directly

Calls 15

eventShouldStartDragFunction · 0.85
isTouchEventFunction · 0.85
inAngleRangesFunction · 0.85
distanceFunction · 0.85
eventShouldEndDragFunction · 0.85
getMethod · 0.80
publishDragSourceMethod · 0.80
isDraggingMethod · 0.65
beginDragMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…