Skip to main content

itemTarget

Description

Fires when the moved item is hovering over the target item

info

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

The event doesn't work with the parent item of a moved item and with a moved item that has the giveItem: false property.

Usage

"itemTarget": ({
id: string | number,
targetId: string | number,
batch: (string | number)[],
event: PointerEvent
}) => boolean | void;

Parameters

The callback of the event is called with an object with the following parameters:

  • id - the id of the moved item
  • targetId - the id of the target item
  • batch - an array of moved elements' ids
  • event - an event object

Returns

The callback returns false to prevent an item from being hovered over the target item; otherwise, true

info

For handling the inner Diagram Editor events you can use the on() method.

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("itemTarget", ({ id, targetId }) => {
console.log(`
Item ${id} is hovering over the item ${targetId}
`);
});

Change log:

  • The batch parameter was added in the v6.0
  • The callback function takes an object as a parameter since v6.0