orb icon indicating copy to clipboard operation
orb copied to clipboard

New: Added support to set node/edge state using custom options

Open parmar-abhinav opened this issue 1 year ago • 1 comments

Issue id: #68

Description: This pull request introduces the mechanism for handling state changes of nodes and edges through the setState method in the Node and Edge classes. Additionally, this enhancement includes optional parameters such as isToggle and isSingle in the setState method, providing greater customization for handling state updates.

Examples:

// Select the node
node.setState({ state: SELECTED });

// Select the node if not selected, otherwise unselect it
node.setState({ state: SELECTED, options: { isToggle: true }});

// Select the node, but unselect any other node that is currently selected (aka only the single node will be selected)
node.setState({ state: SELECTED, options: { isSingle: true }});

parmar-abhinav avatar Jul 23 '23 07:07 parmar-abhinav

This PR contain only one part of the 2 task mentioned in the issue. Implementing setState method in this PR. Thinking of raising separate PR for the task:

The ORB should have a structure to keep nodes/edges by their state (selected, hovered, or even custom user ones - that is the reason why the state can be any number) - this is for easier and faster lookup, currently, you need to iterate through all nodes/edges to get the selected/hovered one which is not an optimal way

parmar-abhinav avatar Jul 23 '23 07:07 parmar-abhinav