MCPcopy
hub / github.com/clauderic/dnd-kit / bind

Method bind

packages/dom/src/core/sensors/drag/DragSensor.ts:32–51  ·  view source on GitHub ↗
(source: Draggable, options: DragSensorOptions)

Source from the content-addressed store, hash-verified

30 }
31
32 public bind(source: Draggable, options: DragSensorOptions): CleanupFunction {
33 const unbind = effect(() => {
34 const target = source.handle ?? source.element;
35 const listener: EventListener = (event: Event) => {
36 if (event instanceof DragEvent) {
37 this.handleDragStart(event, source, options);
38 }
39 };
40
41 if (target) {
42 target.addEventListener('dragstart', listener);
43
44 return () => {
45 target.removeEventListener('dragstart', listener);
46 };
47 }
48 });
49
50 return unbind;
51 }
52
53 private handleDragStart = (
54 event: DragEvent,

Callers 11

constructorMethod · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
DragSensorClass · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
registerEffectFunction · 0.45
derivedFunction · 0.45
constructorMethod · 0.45

Calls 2

addEventListenerMethod · 0.80
removeEventListenerMethod · 0.80

Tested by

no test coverage detected