Skip to main content

beforeItemCatch

info

The event works only in the org chart and mindmap modes of Diagram, the itemsDraggable property must be set to true

Description

Fires before an item is caught

Usage

beforeItemCatch: (
movedId: string | number,
targetId: string | number,
event: MouseEvent
) => boolean | void;

Parameters

The callback of the event takes the following parameters:

  • movedId - (required) the id of the moved item
  • targetId - (required) the id of the target item
  • event - (required) a native HTML event object

Returns

Return false to prevent the item from being caught; 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("beforeItemCatch", (movedId, targetId, event) => {
console.log("beforeItemCatch", movedId, targetId, event);
if (targetId === "2.1") return false;
});

Change log: Added in v4.1