Skip to content

Commit

Permalink
port dragging now using the port position
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wicenec committed Nov 15, 2023
1 parent de63651 commit 4412741
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/GraphRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,6 @@ export class GraphRenderer {
static portDragging = (event:any) : void => {
GraphRenderer.updateMousePos();


// check for nearest matching port in the nearby nodes
const match: {node: Node, field: Field} = GraphRenderer.findNearestMatchingPort(GraphRenderer.mousePosX(), GraphRenderer.mousePosY(), GraphRenderer.portDragSourceNode, GraphRenderer.portDragSourcePort, GraphRenderer.portDragSourcePortIsInput);

Expand Down Expand Up @@ -1323,22 +1322,25 @@ export class GraphRenderer {
let minPort: Field = null;

const portList = GraphRenderer.matchingPortList
console.log(portList)
console.log(portList,positionX,positionY)
for (const x of portList){
const port = x.field
const node = x.node

// get position of port
let portX
let portY

console.log(sourcePortIsInput)
if (sourcePortIsInput){
portX = port.getOutputPosition().x;
portY = port.getOutputPosition().y;
} else {
portX = port.getInputPosition().x;
portY = port.getInputPosition().y;
}
portX = node.getPosition().x + portX
portY = node.getPosition().y + portY
console.log('match location',node.getName(),portX,portY)

// get distance to port
const distance = Math.sqrt( Math.pow(portX - positionX, 2) + Math.pow(portY - positionY, 2) );
Expand Down

0 comments on commit 4412741

Please sign in to comment.