Hi All,
first, thank you for this wonderful library
every time I learned something!
I’m working on my End of study project, and I’m using gojs as my library to draw some diagrams :)
I’m struggling with PortShifting, I called PortShifting.js on my page and I add this code to handle the mouse + shift key event :
myDiagram.toolManager.mouseMoveTools.insertAt(0, new PortShiftingTool());
I’m using dynamic ports (https://gojs.net/latest/samples/dynamicPorts.html)
and I want to add PortShifting for example this is the left port for nodes :
myDiagram.nodeTemplate =
$(go.Node, "Table",
{
dragComputation: stayInViewport,
locationObjectName: "BODY",
locationSpot: go.Spot.Center,
selectionObjectName: "BODY",
linkConnected: function(node, link, port) {
link.data.lead = leadcount();
// port.visible = false;
},
linkDisconnected: function(node, link, port) {
link.data.lead = leadcount();
//port.visible = true;
}
// contextMenu: nodeMenu
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
{selectable: true, selectionAdornmentTemplate: nodeSelectionAdornmentTemplate},
{resizable: true, resizeObjectName: "PANEL", resizeAdornmentTemplate: nodeResizeAdornmentTemplate},
{rotatable: true, rotateAdornmentTemplate: nodeRotateAdornmentTemplate},
// the Panel holding the left port elements, which are themselves Panels,
// created for each item in the itemArray, bound to data.leftArray
$(go.Panel, "Vertical",
new go.Binding("itemArray", "leftArray"),
{
row: 1, column: 0,alignment: go.Spot.Center,
itemTemplate:
$(go.Panel,
{
_side: "left", // internal property to make it easier to tell which side it's on
fromSpot: go.Spot.Left, toSpot: go.Spot.Left,
fromLinkable: true, toLinkable: true, cursor: "pointer",
fromLinkableDuplicates: false,
toLinkableDuplicates:false,
toMaxLinks: 1,
fromMaxLinks:1
},
new go.Binding("margin", "portmargin"),
new go.Binding("portId", "portId"),
$(go.Shape, "Rectangle",
{
stroke: null, strokeWidth: 0,
desiredSize: portSize,
margin: new go.Margin(0, 0,0,0)
},
new go.Binding("fill", "portColor"),
new go.Binding("desiredSize", "desiredSize")
),
$(go.TextBlock, "", // the label text
{
/* textAlign: "center",
font: "9pt helvetica, arial, sans-serif",
margin: 0,
editable: false // enable in-place editing*/
margin: go.Margin.parse("5 0 0 0"),
font: "bold 15px Segoe UI,sans-serif",
editable: false
},
// editing the text automatically updates the model data
new go.Binding("text", "text"))
) // end itemTemplate
}
), // end Vertical Panel
thanks in advance