Skip to main content

beforeItemRotate

Description

Fires before an item is rotated

Usage

"beforeItemRotate": ({
id: string | number,
angle: number
}) => boolean | void;

Parameters

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

  • id - the id of the item being rotated
  • angle - the new rotation angle of the item in degrees

Returns

The callback returns false to prevent the item from being rotated; 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("beforeItemRotate", ({ id, angle }) => {
if (angle > 90 && angle < 270) {
console.log(`Preventing rotation of the item ${id} by this angle.`);
return false; // Prevent rotation
}
console.log(`Rotating the item ${id} by the angle: ${angle}`);
});

Change log:

  • The event is added in v6.1

Related API:

Related samples: