Wrapper to create a drag source from a DOM element so that the element can be dragged over a graph and dropped into the graph as a new cell.
Problem is that in the dropHandler the current preview location is not available, so the preview and the dropHandler must match.
mxDragSource | Wrapper to create a drag source from a DOM element so that the element can be dragged over a graph and dropped into the graph as a new cell. |
Functions | |
mxDragSource | Constructs a new drag source for the given element. |
Variables | |
element | Reference to the DOM node which was made draggable. |
dropHandler | Holds the DOM node that is used to represent the drag preview. |
dragOffset | mxPoint that specifies the offset of the dragElement. |
dragElement | Holds the DOM node that is used to represent the drag preview. |
previewElement | Optional mxRectangle that specifies the unscaled size of the preview. |
previewOffset | Optional mxPoint that specifies the offset of the preview in pixels. |
enabled | Specifies if this drag source is enabled. |
currentGraph | Reference to the mxGraph that is the current drop target. |
currentDropTarget | Holds the current drop target under the mouse. |
currentPoint | Holds the current drop location. |
currentGuide | Holds an mxGuide for the currentGraph if <dragPreview> is not null. |
currentGuide | Holds an mxGuide for the currentGraph if <dragPreview> is not null. |
autoscroll | Specifies if the graph should scroll automatically. |
guidesEnabled | Specifies if mxGuide should be enabled. |
gridEnabled | Specifies if the grid should be allowed. |
highlightDropTargets | Specifies if drop targets should be highlighted. |
dragElementZIndex | ZIndex for the drag element. |
dragElementOpacity | Opacity of the drag element in %. |
checkEventSource | Whether the event source should be checked in <graphContainerEvent>. |
Functions | |
isEnabled | Returns enabled. |
setEnabled | Sets enabled. |
isGuidesEnabled | Returns guidesEnabled. |
setGuidesEnabled | Sets guidesEnabled. |
isGridEnabled | Returns gridEnabled. |
setGridEnabled | Sets gridEnabled. |
getGraphForEvent | Returns the graph for the given mouse event. |
getDropTarget | Returns the drop target for the given graph and coordinates. |
createDragElement | Creates and returns a clone of the <dragElementPrototype> or the element if the former is not defined. |
createPreviewElement | Creates and returns an element which can be used as a preview in the given graph. |
isActive | Returns true if this drag source is active. |
reset | Stops and removes everything and restores the state of the object. |
mouseDown | Returns the drop target for the given graph and coordinates. |
startDrag | Creates the dragElement using createDragElement. |
stopDrag | Invokes removeDragElement. |
removeDragElement | Removes and destroys the dragElement. |
getElementForEvent | Returns the topmost element under the given event. |
graphContainsEvent | Returns true if the given graph contains the given event. |
mouseMove | Gets the graph for the given event using getGraphForEvent, updates the currentGraph, calling dragEnter and dragExit on the new and old graph, respectively, and invokes dragOver if currentGraph is not null. |
mouseUp | Processes the mouse up event and invokes drop, dragExit and stopDrag as required. |
removeListeners | Actives the given graph as a drop target. |
dragEnter | Actives the given graph as a drop target. |
dragExit | Deactivates the given graph as a drop target. |
dragOver | Implements autoscroll, updates the currentPoint, highlights any drop targets and updates the preview. |
drop | Returns the drop target for the given graph and coordinates. |
mxDragSource.prototype.dragOffset
mxPoint that specifies the offset of the dragElement. Default is null.
mxDragSource.prototype.previewElement
Optional mxRectangle that specifies the unscaled size of the preview.
mxDragSource.prototype.previewOffset
Optional mxPoint that specifies the offset of the preview in pixels.
mxDragSource.prototype.currentGraph
Reference to the mxGraph that is the current drop target.
mxDragSource.prototype.currentGuide
Holds an mxGuide for the currentGraph if <dragPreview> is not null.
Holds an mxGuide for the currentGraph if <dragPreview> is not null.
mxDragSource.prototype.guidesEnabled
Specifies if mxGuide should be enabled. Default is true.
mxDragSource.prototype.isEnabled = function()
Returns enabled.
mxDragSource.prototype.setEnabled = function( value )
Sets enabled.
mxDragSource.prototype.isGuidesEnabled = function()
Returns guidesEnabled.
mxDragSource.prototype.setGuidesEnabled = function( value )
Sets guidesEnabled.
mxDragSource.prototype.isGridEnabled = function()
Returns gridEnabled.
mxDragSource.prototype.setGridEnabled = function( value )
Sets gridEnabled.
mxDragSource.prototype.getDropTarget = function( graph, x, y, evt )
Returns the drop target for the given graph and coordinates. This implementation uses mxGraph.getCellAt.
mxDragSource.prototype.createDragElement = function( evt )
Creates and returns a clone of the <dragElementPrototype> or the element if the former is not defined.
mxDragSource.prototype.mouseDown = function( evt )
Returns the drop target for the given graph and coordinates. This implementation uses mxGraph.getCellAt.
To ignore popup menu events for a drag source, this function can be overridden as follows.
let mouseDown = dragSource.mouseDown; dragSource.mouseDown = function(evt) { if (!mxEvent.isPopupTrigger(evt)) { mouseDown.apply(this, arguments); } };
mxDragSource.prototype.startDrag = function( evt )
Creates the dragElement using createDragElement.
mxDragSource.prototype.stopDrag = function()
Invokes removeDragElement.
mxDragSource.prototype.removeDragElement = function()
Removes and destroys the dragElement.
mxDragSource.prototype.mouseMove = function( evt )
Gets the graph for the given event using getGraphForEvent, updates the currentGraph, calling dragEnter and dragExit on the new and old graph, respectively, and invokes dragOver if currentGraph is not null.
mxDragSource.prototype.dragOver = function( graph, evt )
Implements autoscroll, updates the currentPoint, highlights any drop targets and updates the preview.
mxDragSource.prototype.drop = function( graph, evt, dropTarget, x, y )
Returns the drop target for the given graph and coordinates. This implementation uses mxGraph.getCellAt.
Constructs a new drag source for the given element.
function mxDragSource( element, dropHandler )
Reference to the DOM node which was made draggable.
mxDragSource.prototype.element
Holds the DOM node that is used to represent the drag preview.
mxDragSource.prototype.dropHandler
mxPoint that specifies the offset of the dragElement.
mxDragSource.prototype.dragOffset
Holds the DOM node that is used to represent the drag preview.
mxDragSource.prototype.dragElement
Optional mxRectangle that specifies the unscaled size of the preview.
mxDragSource.prototype.previewElement
Optional mxPoint that specifies the offset of the preview in pixels.
mxDragSource.prototype.previewOffset
Specifies if this drag source is enabled.
mxDragSource.prototype.enabled
Reference to the mxGraph that is the current drop target.
mxDragSource.prototype.currentGraph
Holds the current drop target under the mouse.
mxDragSource.prototype.currentDropTarget
Holds the current drop location.
mxDragSource.prototype.currentPoint
Holds an mxGuide for the currentGraph if dragPreview is not null.
mxDragSource.prototype.currentGuide
Specifies if the graph should scroll automatically.
mxDragSource.prototype.autoscroll
Specifies if mxGuide should be enabled.
mxDragSource.prototype.guidesEnabled
Specifies if the grid should be allowed.
mxDragSource.prototype.gridEnabled
Specifies if drop targets should be highlighted.
mxDragSource.prototype.highlightDropTargets
ZIndex for the drag element.
mxDragSource.prototype.dragElementZIndex
Opacity of the drag element in %.
mxDragSource.prototype.dragElementOpacity
Whether the event source should be checked in graphContainerEvent.
mxDragSource.prototype.checkEventSource
Returns enabled.
mxDragSource.prototype.isEnabled = function()
Sets enabled.
mxDragSource.prototype.setEnabled = function( value )
Returns guidesEnabled.
mxDragSource.prototype.isGuidesEnabled = function()
Sets guidesEnabled.
mxDragSource.prototype.setGuidesEnabled = function( value )
Returns gridEnabled.
mxDragSource.prototype.isGridEnabled = function()
Sets gridEnabled.
mxDragSource.prototype.setGridEnabled = function( value )
Returns the graph for the given mouse event.
mxDragSource.prototype.getGraphForEvent = function( evt )
Returns the drop target for the given graph and coordinates.
mxDragSource.prototype.getDropTarget = function( graph, x, y, evt )
Creates and returns a clone of the dragElementPrototype or the element if the former is not defined.
mxDragSource.prototype.createDragElement = function( evt )
Creates and returns an element which can be used as a preview in the given graph.
mxDragSource.prototype.createPreviewElement = function( graph )
Returns true if this drag source is active.
mxDragSource.prototype.isActive = function()
Stops and removes everything and restores the state of the object.
mxDragSource.prototype.reset = function()
Returns the drop target for the given graph and coordinates.
mxDragSource.prototype.mouseDown = function( evt )
Creates the dragElement using createDragElement.
mxDragSource.prototype.startDrag = function( evt )
Invokes removeDragElement.
mxDragSource.prototype.stopDrag = function()
Removes and destroys the dragElement.
mxDragSource.prototype.removeDragElement = function()
Returns the topmost element under the given event.
mxDragSource.prototype.getElementForEvent = function( evt )
Returns true if the given graph contains the given event.
mxDragSource.prototype.graphContainsEvent = function( graph, evt )
Gets the graph for the given event using getGraphForEvent, updates the currentGraph, calling dragEnter and dragExit on the new and old graph, respectively, and invokes dragOver if currentGraph is not null.
mxDragSource.prototype.mouseMove = function( evt )
Actives the given graph as a drop target.
mxDragSource.prototype.dragEnter = function( graph, evt )
Deactivates the given graph as a drop target.
mxDragSource.prototype.dragExit = function( graph, evt )
Implements autoscroll, updates the currentPoint, highlights any drop targets and updates the preview.
mxDragSource.prototype.dragOver = function( graph, evt )
Processes the mouse up event and invokes drop, dragExit and stopDrag as required.
mxDragSource.prototype.mouseUp = function( evt )
Returns the drop target for the given graph and coordinates.
mxDragSource.prototype.drop = function( graph, evt, dropTarget, x, y )
Actives the given graph as a drop target.
mxDragSource.prototype.removeListeners = function()
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.
mxGraph.prototype.getCellAt = function( x, y, parent, vertices, edges, ignoreFn )