MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / _mouseEnter

Method _mouseEnter

src/dd-droppable.ts:84–109  ·  view source on GitHub ↗

@internal called when the cursor enters our area - prepare for a possible drop and track leaving

(e: MouseEvent)

Source from the content-addressed store, hash-verified

82
83 /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
84 protected _mouseEnter(e: MouseEvent): void {
85 // console.log(`${count++} Enter ${this.el.id}`); // TEST
86 if (!DDManager.dragElement) return;
87 // During touch drag operations, ignore real browser-generated mouseenter events (isTrusted:true) vs our simulated ones (isTrusted:false).
88 // The browser can fire spurious mouseenter events when we dispatch simulated mousemove events.
89 if (DDTouch.touchHandled && e.isTrusted) return
90
91 if (!this._canDrop(DDManager.dragElement.el)) return;
92 e.preventDefault();
93 e.stopPropagation();
94 DDManager.dragElement._stopScrolling();
95
96 // make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do
97 if (DDManager.dropElement && DDManager.dropElement !== this) {
98 DDManager.dropElement._mouseLeave(e as DragEvent, true); // calledByEnter = true
99 }
100 DDManager.dropElement = this;
101
102 const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dropover' });
103 if (this.option.over) {
104 this.option.over(ev, this._ui(DDManager.dragElement))
105 }
106 this.triggerEvent('dropover', ev);
107 this.el.classList.add('ui-droppable-over');
108 // console.log('tracking'); // TEST
109 }
110
111 /** @internal called when the item is leaving our area, stop tracking if we had moving item */
112 protected _mouseLeave(e: MouseEvent, calledByEnter = false): void {

Callers 2

_mouseLeaveMethod · 0.80

Calls 7

_canDropMethod · 0.95
_uiMethod · 0.95
_stopScrollingMethod · 0.80
_mouseLeaveMethod · 0.80
initEventMethod · 0.80
triggerEventMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected