beforeItemMove
Description
Fires before an item is moved
note
The event doesn't work with the line object
Usage
beforeItemMove: (
event: MouseEvent,
id: string | number,
coord: object
) => boolean | void;
Parameters
The callback of the event takes the following parameters:
event
- (required) a native HTML event objectid
- (required) the id of an itemcoord
- (required) an object with the x and y coordinates of the item position before movement
Returns
Return false
to prevent the item from being moved; otherwise, true
Example
// initializing Diagram Editor
const editor = new dhx.DiagramEditor("editor_container");
// loading data
editor.parse(data);
// attaching a handler to the event
editor.events.on("beforeItemMove", (event, id, coordinates) => {
console.log(`
Item ${id} is position:
x: ${coordinates.x}
y: ${coordinates.y}
`);
return true;
});
Change log: Added in v4.0