go.Link.Bezier snap grid

I’m using gojs go.Link.Bezier. But I have some problems when using this link type. For example, when I link the link to the next note, the link does not become flat.

As seen, it is really hard to make the link straight.

Does go.Link.Bezier have a snap on this link type?

The gif at the bottom is really easy to use as seen in
Is it possible to do this in gojs?
can i do like here

You just need to override the LinkingTool.doMouseMove to snap the current InputEvent point.

      $(go.Diagram, . . .,
            . . .,
            "linkingTool.doMouseMove": function() {
              if (this.isActive) {
                var e = this.diagram.lastInput;
                e.documentPoint = e.documentPoint.copy().snapToGrid(0, 0, 10, 10);
                e.viewPoint = this.diagram.transformDocToView(e.documentPoint);

You might want to do the same on doMouseUp. But you already have such an override, don’t you? So that you can show the menu of kinds of nodes to create and link to?

I’ve override linking Tool.MouseMove but when I tried your code I didn’t get any results. still not snap

can you review your code? Can you show your code in a working environment?

By the way I’m using NonDraggingRealTime as draggingTool. I get no results when I remove NonDraggingRealTime

I copied that code from a working sample. It should work in any sample that supports user-drawn links, unless it conflicts with another customization of the LinkingTool.

You should be overriding doMouseMove, not MouseMove.

I’ve implemented your code, but as you can see, the link grid doesn’t snap.
Please see the example in the link

If you a link from Node you will see that the link is not snap

If I’m making a mistake, can you fix it?


Can you share your sample application with me?

I just tried it in your codepen, and it does work as designed. Maybe you want to increase the cell size to which it is snapping.

I think you misunderstood me.

In this example, the link is snap. Can I tell you my problem?

Watch the link. step by step link

Is it possible to do so in gojs. I tried your code and didn’t get results. can you share a working example?

Yes, in your codepen the end of the link is snapping to grid points as the user is moving the mouse. Is that not what you are asking for?