What is your code that corresponds with the move
function in my sample?
It’s working as expected, @walter.
Quick question — We need to set an offset or a “safe” position on the Group Node to Mouse Enter & to ensure that no other GraphObjects are at that same coordinates? Is there a way to handle this with some generic logic?
First, the design of your Group should ensure that there is a point where there will not be any member Nodes.
Second, depending on the design of your app, it might be impossible to guarantee that there will not be any overlapping Nodes or Links at any given point of your Group. Users might drag nodes so that they overlap. Or Links crossing over to connect with a member Node might do so anywhere, depending on where they come from or go to.
Sure @walter.
Quick question - Item instanceof go.Group is this valid? I am aware instanceof go.Link is valid. Just want to check if the same valid for Group?
Group is a subclass of Node, which is a subclass of Part.
Yes, you can instanceof
any JavaScript class.
Currently, we’re using the GoJS Robot.js extension to determine the position of links and groups for simulating mouse events, particularly in accessibility-related use cases. Is this a reliable long-term approach, especially in complex diagrams where elements may overlap? Are there more robust or recommended alternatives for handling such scenarios within GoJS?
Using Robot is very robust – much more so than trying to use real mouse or touch events.
However, it is still creating input events and processing them. You could think of manipulating the HTML DOM as a more robust way to find and examine and modify HTML elements. You can do that with GoJS by setting Diagram.renderer to “svg” and then manipulate the SVG DOM.
An even more fundamental technique is to manipulate the GoJS GraphObjects that are in the Diagram. Those are basically the DOM elements of each Diagram and will exist in memory even if they are outside of the viewport, unless you have implemented virtualization. Usually you would start with the Diagram and use its properties and methods to get at whatever you want.
Are there any reference examples for manipulating GoJS GraphObjects
within a Diagram
that includes interactive elements and complex group nodes and links? Which is specific to A11y?
Most of the GoJS documentation is exactly that. Almost everything has something to do with Diagrams, Nodes, Links, and Models and their data.
For example, Diagram.nodes is the collection of Nodes in a Diagram: Diagram | GoJS API
You could then iterate over that collection to search for a particular Node, probably by looking at its Node.data.
In GoJS v2:
for (const it = diagram.nodes; it.next();) {
const n = it.value;
if (n.data.someProp === "someValue") {
// now n is a Node whose model data has a particular value for a particular property
}
}
In GoJS v3:
for (const n of diagram.nodes) {
if (n.data.someProp === "someValue") {
// now n is a Node whose model data has a particular value for a particular property
}
}
More examples: Collections | GoJS