@internal call when mouse goes down before a dragstart happens
(e: MouseEvent)
| 146 | |
| 147 | /** @internal call when mouse goes down before a dragstart happens */ |
| 148 | protected _mouseDown(e: MouseEvent): boolean { |
| 149 | // if real brower event (trusted:true vs false for our simulated ones) and we didn't correctly clear the last touch event, clear things up |
| 150 | if (DDTouch.touchHandled && e.isTrusted) DDTouch.touchHandled = false; |
| 151 | |
| 152 | // don't let more than one widget handle mouseStart |
| 153 | if (DDManager.mouseHandled) return; |
| 154 | if (e.button !== 0) return true; // only left click |
| 155 | |
| 156 | // make sure we are not clicking on known object that handles mouseDown, or ones supplied by the user |
| 157 | if (!this.dragEls.find(el => el === e.target) && (e.target as HTMLElement).closest(skipMouseDown)) return true; |
| 158 | if (this.option.cancel) { |
| 159 | if ((e.target as HTMLElement).closest(this.option.cancel)) return true; |
| 160 | } |
| 161 | |
| 162 | this.mouseDownEvent = e; |
| 163 | delete this.dragging; |
| 164 | delete DDManager.dragElement; |
| 165 | delete DDManager.dropElement; |
| 166 | delete this._autoScrollMaxSpeed; |
| 167 | delete this._autoScrollContainer; |
| 168 | // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack |
| 169 | document.addEventListener('mousemove', this._mouseMove, { capture: true, passive: true }); // true=capture, not bubble |
| 170 | document.addEventListener('mouseup', this._mouseUp, true); |
| 171 | if (isTouch) { |
| 172 | e.currentTarget.addEventListener('touchmove', touchmove); |
| 173 | e.currentTarget.addEventListener('touchend', touchend); |
| 174 | } |
| 175 | |
| 176 | e.preventDefault(); |
| 177 | // preventDefault() prevents blur event which occurs just after mousedown event. |
| 178 | // if an editable content has focus, then blur must be call |
| 179 | if (document.activeElement) (document.activeElement as HTMLElement).blur(); |
| 180 | |
| 181 | DDManager.mouseHandled = true; |
| 182 | return true; |
| 183 | } |
| 184 | |
| 185 | /** @internal method to call actual drag event */ |
| 186 | public _callDrag(e: DragEvent): void { |