phosphor-domutil
Advanced tools
Comparing version 1.0.1 to 1.1.0-alpha.0
@@ -163,1 +163,294 @@ import { IDisposable } from 'phosphor-disposable'; | ||
export declare function sizeLimits(node: HTMLElement): ISizeLimits; | ||
/** | ||
* The data object for a single drag and drop life cycle. | ||
*/ | ||
export interface IDragDropData { | ||
/** | ||
* A reference to the HTML element that follows the cursor. | ||
*/ | ||
ghost: HTMLElement; | ||
/** | ||
* A disposable invoked on drag end. | ||
* | ||
* This can be useful in conjunction with [[overrideCursor]]. | ||
*/ | ||
override: IDisposable; | ||
/** | ||
* A key/value map of MIMEs/payloads for different drop targets. | ||
*/ | ||
payload: { | ||
[mime: string]: any; | ||
}; | ||
/** | ||
* The starting X coordinate of a drag operation. | ||
*/ | ||
startX: number; | ||
/** | ||
* The starting Y coordinate of a drag operation. | ||
*/ | ||
startY: number; | ||
} | ||
/** | ||
* A handler that provides a simple interface to make a node a drop target. | ||
* | ||
* #### Example | ||
* ```typescript | ||
* import { DropHandler, IDragDropData } from 'phosphor-domutil'; | ||
* import { Widget } from 'phosphor-widget'; | ||
* | ||
* class DroppableWidget extends Widget { | ||
* constructor() { | ||
* super(); | ||
* this._dropHandler = new DropHandler(this.node, this); | ||
* this._dropHandler.onDragEnter = this._onDragEnter; | ||
* this._dropHandler.onDragLeave = this._onDragLeave; | ||
* this._dropHandler.onDrag = this._onDrag; | ||
* this._dropHandler.onDrop = this._onDrop; | ||
* } | ||
* dispose(): void { | ||
* this._dropHandler.dispose(); | ||
* super.dispose(); | ||
* } | ||
* private _onDragEnter(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag enter', dragData); | ||
* } | ||
* private _onDragLeave(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag leave', dragData); | ||
* } | ||
* private _onDrag(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag', dragData); | ||
* } | ||
* private _onDrop(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drop', dragData); | ||
* } | ||
* private _dropHandler: DropHandler; | ||
* } | ||
* ``` | ||
*/ | ||
export declare class DropHandler implements IDisposable { | ||
/** | ||
* Add a drop handler instance to the registry. | ||
* | ||
* @param handler - The drop handler being registered. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
static register(handler: DropHandler): void; | ||
/** | ||
* Remove a drop handler instance from the registry. | ||
* | ||
* @param handler - The drop handler being deregistered. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
static deregister(handler: DropHandler): void; | ||
/** | ||
* Expire the cached values tied to a specific drag/drop lifecycle. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
static invalidateCache(): void; | ||
/** | ||
* Deploy a drag event to the relevant drop handlers. | ||
* | ||
* @param action - The event type being deployed (either `'drag'` or | ||
* `'drop'`). | ||
* | ||
* @param event - The native mouse event that underlies the operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
static deploy(action: string, event: MouseEvent, dragData: IDragDropData): void; | ||
/** | ||
* Construct a new drop handler. | ||
* | ||
* @param node - The node that event listeners are attached to. | ||
* | ||
* @param context - The context within which to fire event handlers. | ||
*/ | ||
constructor(node: Node, context: any); | ||
/** | ||
* Dispose of the reference to a drop handler in the registry. | ||
*/ | ||
dispose(): void; | ||
/** | ||
* Check if a drop handler is disposed. | ||
*/ | ||
isDisposed: boolean; | ||
/** | ||
* Handle the drag enter event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
onDragEnter: (event: MouseEvent, dragData: IDragDropData) => void; | ||
/** | ||
* Handle the drag event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
onDrag: (event: MouseEvent, dragData: IDragDropData) => void; | ||
/** | ||
* Handle the drag leave event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
onDragLeave: (event: MouseEvent, dragData: IDragDropData) => void; | ||
/** | ||
* Handle the drop event. | ||
* | ||
* @param event - The native mouse event that underlies the drop operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
onDrop: (event: MouseEvent, dragData: IDragDropData) => void; | ||
private _id; | ||
private _node; | ||
private _context; | ||
} | ||
/** | ||
* A handler that provides a simple interface to make a node draggable. | ||
* | ||
* #### Example | ||
* ```typescript | ||
* import { DragHandler, IDragDropData } from 'phosphor-domutil'; | ||
* import { Widget } from 'phosphor-widget'; | ||
* | ||
* class DraggableWidget extends Widget { | ||
* constructor() { | ||
* super(); | ||
* this._payload = () => { return new Widget(); }; | ||
* this._dragHandler = new DragHandler(this.node, this); | ||
* this._dragHandler.onDragStart = this._onDragStart; | ||
* this._dragHandler.onDragEnd = this._onDragEnd; | ||
* } | ||
* dispose(): void { | ||
* this._dragHandler.dispose(); | ||
* super.dispose(); | ||
* } | ||
* private _onDragStart(event: MouseEvent, dragData: IDragDropData): void { | ||
* dragData.payload['application/x-phosphor-example'] = this._payload; | ||
* console.log('drag start', dragData); | ||
* } | ||
* private _onDragEnd(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag end', dragData); | ||
* } | ||
* private _dragHandler: DragHandler = null; | ||
* private _payload: () => Widget = null; | ||
* } | ||
* ``` | ||
*/ | ||
export declare class DragHandler implements IDisposable { | ||
/** | ||
* Flag to determine if a drag handler will automatically catch drag events. | ||
* | ||
* #### Notes | ||
* If set to `false`, dragging will not automatically begin once the | ||
* `threshold` has been crossed. The `startDrag` method will need to be | ||
* invoked in order to inform the drag handler that a drag operation has | ||
* started. | ||
* | ||
* **See also:** [[startDrag]] | ||
*/ | ||
autostart: boolean; | ||
/** | ||
* The default dragging threshold in pixels. | ||
*/ | ||
dragThreshold: number; | ||
/** | ||
* Construct a new drag handler. | ||
* | ||
* @param node - The node that is being dragged. | ||
* | ||
* @param context - The context within which to fire event handlers. | ||
*/ | ||
constructor(node: Node, context: any); | ||
/** | ||
* Dispose of the resources the drag handler created. | ||
*/ | ||
dispose(): void; | ||
/** | ||
* Check if a drag handler is disposed. | ||
*/ | ||
isDisposed: boolean; | ||
/** | ||
* Create an HTML element that will follow the cursor in drag/drop operations. | ||
*/ | ||
ghost(): HTMLElement; | ||
/** | ||
* Handle the DOM events for the drag handler. | ||
* | ||
* @param event - The DOM event sent to the drag handler. | ||
* | ||
* #### Notes | ||
* This method implements the DOM `EventListener` interface and is | ||
* called in response to events on the drag handler's parent DOM node. It | ||
* should not be called directly by user code. | ||
*/ | ||
handleEvent(event: Event): void; | ||
/** | ||
* Handle the drag start event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
onDragStart: (event: MouseEvent, dragData: IDragDropData) => void; | ||
/** | ||
* Handle the drag end event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
onDragEnd: (event: MouseEvent, dragData: IDragDropData) => void; | ||
/** | ||
* Start a drag operation manually. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* #### Notes | ||
* This method only needs to be used if the `autostart` flag for a drag | ||
* handler has been set to `false`. | ||
* | ||
* **See also:** [[autostart]] | ||
*/ | ||
startDrag(event: MouseEvent): void; | ||
/** | ||
* Create drag data for a drag and drop lifecycle. | ||
*/ | ||
private _createDragData(event); | ||
/** | ||
* Handle the `'mousedown'` event for the drag handler. | ||
*/ | ||
private _evtMouseDown(event); | ||
/** | ||
* Handle the `'mousemove'` event for the drag handler. | ||
*/ | ||
private _evtMouseMove(event); | ||
/** | ||
* Handle the `'mouseup'` event for the drag handler. | ||
*/ | ||
private _evtMouseUp(event); | ||
private _dragData; | ||
private _node; | ||
private _context; | ||
} |
452
lib/index.js
@@ -16,2 +16,6 @@ /*----------------------------------------------------------------------------- | ||
/** | ||
* The class name added to the ghost node that follows the cursor during drags. | ||
*/ | ||
var DRAG_GHOST_CLASS = 'p-mod-ghost'; | ||
/** | ||
* The id for the active cursor override. | ||
@@ -168,2 +172,450 @@ */ | ||
exports.sizeLimits = sizeLimits; | ||
/** | ||
* The id for drop handle instances. | ||
*/ | ||
var dropHandlerID = 0; | ||
/** | ||
* The registry of drop records. | ||
*/ | ||
var dropHandlerRegistry = Object.create(null); | ||
/** | ||
* A handler that provides a simple interface to make a node a drop target. | ||
* | ||
* #### Example | ||
* ```typescript | ||
* import { DropHandler, IDragDropData } from 'phosphor-domutil'; | ||
* import { Widget } from 'phosphor-widget'; | ||
* | ||
* class DroppableWidget extends Widget { | ||
* constructor() { | ||
* super(); | ||
* this._dropHandler = new DropHandler(this.node, this); | ||
* this._dropHandler.onDragEnter = this._onDragEnter; | ||
* this._dropHandler.onDragLeave = this._onDragLeave; | ||
* this._dropHandler.onDrag = this._onDrag; | ||
* this._dropHandler.onDrop = this._onDrop; | ||
* } | ||
* dispose(): void { | ||
* this._dropHandler.dispose(); | ||
* super.dispose(); | ||
* } | ||
* private _onDragEnter(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag enter', dragData); | ||
* } | ||
* private _onDragLeave(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag leave', dragData); | ||
* } | ||
* private _onDrag(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag', dragData); | ||
* } | ||
* private _onDrop(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drop', dragData); | ||
* } | ||
* private _dropHandler: DropHandler; | ||
* } | ||
* ``` | ||
*/ | ||
var DropHandler = (function () { | ||
/** | ||
* Construct a new drop handler. | ||
* | ||
* @param node - The node that event listeners are attached to. | ||
* | ||
* @param context - The context within which to fire event handlers. | ||
*/ | ||
function DropHandler(node, context) { | ||
/** | ||
* Handle the drag enter event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
this.onDragEnter = null; | ||
/** | ||
* Handle the drag event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
this.onDrag = null; | ||
/** | ||
* Handle the drag leave event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
this.onDragLeave = null; | ||
/** | ||
* Handle the drop event. | ||
* | ||
* @param event - The native mouse event that underlies the drop operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
this.onDrop = null; | ||
this._id = null; | ||
this._node = null; | ||
this._context = null; | ||
this._node = node; | ||
this._context = context; | ||
DropHandler.register(this); | ||
} | ||
/** | ||
* Add a drop handler instance to the registry. | ||
* | ||
* @param handler - The drop handler being registered. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
DropHandler.register = function (handler) { | ||
var id = ++dropHandlerID; | ||
handler._id = id; | ||
dropHandlerRegistry[id] = { | ||
entered: false, | ||
handler: handler, | ||
rect: null | ||
}; | ||
}; | ||
/** | ||
* Remove a drop handler instance from the registry. | ||
* | ||
* @param handler - The drop handler being deregistered. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
DropHandler.deregister = function (handler) { | ||
if (handler._id && dropHandlerRegistry[handler._id]) { | ||
delete dropHandlerRegistry[handler._id]; | ||
} | ||
}; | ||
/** | ||
* Expire the cached values tied to a specific drag/drop lifecycle. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
DropHandler.invalidateCache = function () { | ||
Object.keys(dropHandlerRegistry).forEach(function (key) { | ||
dropHandlerRegistry[key].rect = null; | ||
}); | ||
}; | ||
/** | ||
* Deploy a drag event to the relevant drop handlers. | ||
* | ||
* @param action - The event type being deployed (either `'drag'` or | ||
* `'drop'`). | ||
* | ||
* @param event - The native mouse event that underlies the operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
* | ||
* #### Notes | ||
* This method should not need to be used by any clients of this library. | ||
*/ | ||
DropHandler.deploy = function (action, event, dragData) { | ||
var x = event.clientX; | ||
var y = event.clientY; | ||
var keys = Object.keys(dropHandlerRegistry); | ||
for (var _i = 0; _i < keys.length; _i++) { | ||
var key = keys[_i]; | ||
// Multiple drop targets might match. For now, all of them will be fired, | ||
// but in the future, this behavior might change. | ||
var droppable = dropHandlerRegistry[key]; | ||
var context = droppable.handler._context; | ||
var node = droppable.handler._node; | ||
// At the beginning of a drag, cache the bounding rectangle. | ||
if (!droppable.rect) { | ||
droppable.rect = node.getBoundingClientRect(); | ||
} | ||
var _a = droppable.rect, left = _a.left, top_1 = _a.top, right = _a.right, bottom = _a.bottom; | ||
if (x >= left && y >= top_1 && x < right && y < bottom) { | ||
if (!droppable.entered) { | ||
droppable.entered = true; | ||
if (droppable.handler.onDragEnter) { | ||
droppable.handler.onDragEnter.call(context, event, dragData); | ||
} | ||
} | ||
switch (action) { | ||
case 'drag': | ||
if (droppable.handler.onDrag) { | ||
droppable.handler.onDrag.call(context, event, dragData); | ||
} | ||
break; | ||
case 'drop': | ||
if (droppable.handler.onDrop) { | ||
droppable.handler.onDrop.call(context, event, dragData); | ||
} | ||
break; | ||
} | ||
} | ||
else if (droppable.entered) { | ||
droppable.entered = false; | ||
if (droppable.handler.onDragLeave) { | ||
droppable.handler.onDragLeave.call(context, event, dragData); | ||
} | ||
} | ||
} | ||
; | ||
}; | ||
/** | ||
* Dispose of the reference to a drop handler in the registry. | ||
*/ | ||
DropHandler.prototype.dispose = function () { | ||
DropHandler.deregister(this); | ||
this._context = null; | ||
this._node = null; | ||
}; | ||
Object.defineProperty(DropHandler.prototype, "isDisposed", { | ||
/** | ||
* Check if a drop handler is disposed. | ||
*/ | ||
get: function () { | ||
return this._node === null; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return DropHandler; | ||
})(); | ||
exports.DropHandler = DropHandler; | ||
/** | ||
* A handler that provides a simple interface to make a node draggable. | ||
* | ||
* #### Example | ||
* ```typescript | ||
* import { DragHandler, IDragDropData } from 'phosphor-domutil'; | ||
* import { Widget } from 'phosphor-widget'; | ||
* | ||
* class DraggableWidget extends Widget { | ||
* constructor() { | ||
* super(); | ||
* this._payload = () => { return new Widget(); }; | ||
* this._dragHandler = new DragHandler(this.node, this); | ||
* this._dragHandler.onDragStart = this._onDragStart; | ||
* this._dragHandler.onDragEnd = this._onDragEnd; | ||
* } | ||
* dispose(): void { | ||
* this._dragHandler.dispose(); | ||
* super.dispose(); | ||
* } | ||
* private _onDragStart(event: MouseEvent, dragData: IDragDropData): void { | ||
* dragData.payload['application/x-phosphor-example'] = this._payload; | ||
* console.log('drag start', dragData); | ||
* } | ||
* private _onDragEnd(event: MouseEvent, dragData: IDragDropData): void { | ||
* console.log('drag end', dragData); | ||
* } | ||
* private _dragHandler: DragHandler = null; | ||
* private _payload: () => Widget = null; | ||
* } | ||
* ``` | ||
*/ | ||
var DragHandler = (function () { | ||
/** | ||
* Construct a new drag handler. | ||
* | ||
* @param node - The node that is being dragged. | ||
* | ||
* @param context - The context within which to fire event handlers. | ||
*/ | ||
function DragHandler(node, context) { | ||
/** | ||
* Flag to determine if a drag handler will automatically catch drag events. | ||
* | ||
* #### Notes | ||
* If set to `false`, dragging will not automatically begin once the | ||
* `threshold` has been crossed. The `startDrag` method will need to be | ||
* invoked in order to inform the drag handler that a drag operation has | ||
* started. | ||
* | ||
* **See also:** [[startDrag]] | ||
*/ | ||
this.autostart = true; | ||
/** | ||
* The default dragging threshold in pixels. | ||
*/ | ||
this.dragThreshold = 5; | ||
/** | ||
* Handle the drag start event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
this.onDragStart = null; | ||
/** | ||
* Handle the drag end event. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* @param dragData - A reference to the drag/drop context used to pass data | ||
* between the different stages of the drag and drop lifecycle. | ||
*/ | ||
this.onDragEnd = null; | ||
this._dragData = null; | ||
this._node = null; | ||
this._context = null; | ||
this._node = node; | ||
this._context = context; | ||
node.addEventListener('mousedown', this); | ||
} | ||
/** | ||
* Dispose of the resources the drag handler created. | ||
*/ | ||
DragHandler.prototype.dispose = function () { | ||
this._node.removeEventListener('mousedown', this); | ||
this._node = null; | ||
this._context = null; | ||
}; | ||
Object.defineProperty(DragHandler.prototype, "isDisposed", { | ||
/** | ||
* Check if a drag handler is disposed. | ||
*/ | ||
get: function () { | ||
return this._node === null; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Create an HTML element that will follow the cursor in drag/drop operations. | ||
*/ | ||
DragHandler.prototype.ghost = function () { | ||
var node = this._node.cloneNode(true); | ||
var rect = this._node.getBoundingClientRect(); | ||
node.style.height = rect.height + "px"; | ||
node.style.width = rect.width + "px"; | ||
node.classList.add(DRAG_GHOST_CLASS); | ||
return node; | ||
}; | ||
/** | ||
* Handle the DOM events for the drag handler. | ||
* | ||
* @param event - The DOM event sent to the drag handler. | ||
* | ||
* #### Notes | ||
* This method implements the DOM `EventListener` interface and is | ||
* called in response to events on the drag handler's parent DOM node. It | ||
* should not be called directly by user code. | ||
*/ | ||
DragHandler.prototype.handleEvent = function (event) { | ||
switch (event.type) { | ||
case 'mousedown': | ||
this._evtMouseDown(event); | ||
break; | ||
case 'mousemove': | ||
this._evtMouseMove(event); | ||
break; | ||
case 'mouseup': | ||
this._evtMouseUp(event); | ||
break; | ||
} | ||
}; | ||
/** | ||
* Start a drag operation manually. | ||
* | ||
* @param event - The native mouse event that underlies the drag operation. | ||
* | ||
* #### Notes | ||
* This method only needs to be used if the `autostart` flag for a drag | ||
* handler has been set to `false`. | ||
* | ||
* **See also:** [[autostart]] | ||
*/ | ||
DragHandler.prototype.startDrag = function (event) { | ||
if (!this._dragData) { | ||
this._createDragData(event); | ||
} | ||
if (this._dragData._started) { | ||
return; | ||
} | ||
this._dragData._started = true; | ||
this._dragData.ghost = this.ghost(); | ||
document.body.appendChild(this._dragData.ghost); | ||
if (this.onDragStart) { | ||
this.onDragStart.call(this._context, event, this._dragData); | ||
} | ||
}; | ||
/** | ||
* Create drag data for a drag and drop lifecycle. | ||
*/ | ||
DragHandler.prototype._createDragData = function (event) { | ||
this._dragData = { | ||
_started: false, | ||
ghost: null, | ||
override: null, | ||
payload: Object.create(null), | ||
startX: event.clientX, | ||
startY: event.clientY | ||
}; | ||
}; | ||
/** | ||
* Handle the `'mousedown'` event for the drag handler. | ||
*/ | ||
DragHandler.prototype._evtMouseDown = function (event) { | ||
if (event.button !== 0) { | ||
return; | ||
} | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
document.addEventListener('mousemove', this, true); | ||
document.addEventListener('mouseup', this, true); | ||
this._createDragData(event); | ||
}; | ||
/** | ||
* Handle the `'mousemove'` event for the drag handler. | ||
*/ | ||
DragHandler.prototype._evtMouseMove = function (event) { | ||
if (!this._dragData._started) { | ||
if (!this.autostart) { | ||
return; | ||
} | ||
var dx = Math.abs(event.clientX - this._dragData.startX); | ||
var dy = Math.abs(event.clientY - this._dragData.startY); | ||
if (Math.sqrt(dx * dx + dy * dy) >= this.dragThreshold) { | ||
this.startDrag(event); | ||
} | ||
else { | ||
return; | ||
} | ||
} | ||
this._dragData.ghost.style.top = event.clientY + "px"; | ||
this._dragData.ghost.style.left = event.clientX + "px"; | ||
DropHandler.deploy('drag', event, this._dragData); | ||
}; | ||
/** | ||
* Handle the `'mouseup'` event for the drag handler. | ||
*/ | ||
DragHandler.prototype._evtMouseUp = function (event) { | ||
document.removeEventListener('mousemove', this, true); | ||
document.removeEventListener('mouseup', this, true); | ||
if (this._dragData._started) { | ||
if (this._dragData.ghost) { | ||
document.body.removeChild(this._dragData.ghost); | ||
} | ||
DropHandler.invalidateCache(); | ||
DropHandler.deploy('drop', event, this._dragData); | ||
if (this.onDragEnd) { | ||
this.onDragEnd.call(this._context, event, this._dragData); | ||
} | ||
} | ||
if (this._dragData.override) { | ||
this._dragData.override.dispose(); | ||
} | ||
this._dragData = null; | ||
}; | ||
return DragHandler; | ||
})(); | ||
exports.DragHandler = DragHandler; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "phosphor-domutil", | ||
"version": "1.0.1", | ||
"version": "1.1.0-alpha.0", | ||
"description": "Utilities for working with the DOM.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
42789
1086
0
2
1