Zoom to fit diagram mix with html elements

Ok I understand what you are trying say they are independent I am just asking if I found some point on screen How i am going translate into gojs thats it

I just told you how to do that. You just need to get the point’s position in the diagram’s Div and then call Diagram.transformViewToDoc.

Ok thank you

Reading this might help: GoJS Coordinate Systems-- Northwoods Software

I guess we dont have something similar for diagram like node groups you gave answer ResizingTool.dragsMembers make false keep items on place but why on diagram also items positions changing when resize canvas

The position and Part.location properties of Nodes do not change value as the Div changes.

Thats your answer and i can see that position changed

Yes you are right positions its not changing sorry but i cannot keep those blocks on center I am so confuse I dont know what to do

Hi @walter , as you can see from above example the diagram as well as its items (nodes, groups etc.) slides from right to left when diagram resized. We want to stays items in fixed position when diagram resized.

Did you really want to have event handlers for both “#menu-toggle” and “.menu-toggle”? There’s some infinite loop going on.

I already gave a possible solution, above:

Maybe something like:

const pos = myDiagram.position.copy();
pos.x -= (...shift_in_pixels...) / myDiagram.scale;
myDiagram.position = pos;

But I haven’t tested this.

As i understand with your comment, there is no built-in option/flag to fix sliding items when diagram resized right? We need to add something like above code which you provide us to fix this issue.

I think the problem is that the Div element that is hosting the Diagram is either not changing size or changing size in a way that it does not have a policy to maintain. If it were, then zoomToFit would do what you expect. But placing some DOM elements in front of some areas of the diagram’s Div appears to contract the user-visible area in ways that the GoJS library (or any other component) cannot anticipate.

In any case I would expect it to be easy to fix with some code that is run, preferably just before the changes to the DOM, but possibly just after.