Skip to main content

beforeCollapse

fires before collapsing an item

beforeCollapse: (id: Id, dir?: TreeDirection) => boolean | void;

Parameters:

  • id: string | number - the id of an item
  • dir: string - optional, the side the children will be hidden in relation to the parent shape ("left" or "right" for type:"topic", otherwise - undefined)

Returns:

Return false to block collapsing an item; otherwise, true.

Example

diagram.events.on("beforeCollapse", function(id, dir) {
console.log("Collapsing " + diagram.data.getItem(id).text, dir);
return true;
});

Related sample: Diagram. Org chart mode. Events

Change log:

The dir parameter has been added in v3.1.