@internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen
(e: DragEvent)
| 194 | |
| 195 | /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */ |
| 196 | protected _mouseMove(e: DragEvent): boolean { |
| 197 | // console.log(`${count++} move ${e.x},${e.y}`) |
| 198 | const s = this.mouseDownEvent; |
| 199 | this.lastDrag = e; |
| 200 | |
| 201 | if (this.dragging) { |
| 202 | this._dragFollow(e); |
| 203 | // delay actual grid handling drag until we pause for a while if set |
| 204 | if (DDManager.pauseDrag) { |
| 205 | const pause = Number.isInteger(DDManager.pauseDrag) ? DDManager.pauseDrag as number : 100; |
| 206 | if (this.dragTimeout) window.clearTimeout(this.dragTimeout); |
| 207 | this.dragTimeout = window.setTimeout(() => this._callDrag(e), pause); |
| 208 | } else { |
| 209 | this._callDrag(e); |
| 210 | } |
| 211 | } else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) { |
| 212 | /** |
| 213 | * don't start unless we've moved at least 3 pixels |
| 214 | */ |
| 215 | this.dragging = true; |
| 216 | DDManager.dragElement = this; |
| 217 | // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave) |
| 218 | const grid = this.el.gridstackNode?.grid; |
| 219 | if (grid) { |
| 220 | DDManager.dropElement = (grid.el as DDElementHost).ddElement.ddDroppable; |
| 221 | } else { |
| 222 | delete DDManager.dropElement; |
| 223 | } |
| 224 | this.helper = this._createHelper(); |
| 225 | this._setupHelperContainmentStyle(); |
| 226 | this.dragTransform = Utils.getValuesFromTransformedElement(this.helperContainment); |
| 227 | this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment); |
| 228 | this._setupHelperStyle(e); |
| 229 | |
| 230 | const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstart' }); |
| 231 | if (this.option.start) { |
| 232 | this.option.start(ev, this.ui()); |
| 233 | } |
| 234 | this.triggerEvent('dragstart', ev); |
| 235 | // now track keyboard events to cancel or rotate |
| 236 | document.addEventListener('keydown', this._keyEvent); |
| 237 | } |
| 238 | // e.preventDefault(); // passive = true. OLD: was needed otherwise we get text sweep text selection as we drag around |
| 239 | return true; |
| 240 | } |
| 241 | |
| 242 | /** @internal call when the mouse gets released to drop the item at current location */ |
| 243 | protected _mouseUp(e: MouseEvent): void { |
no test coverage detected