1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Highlight port on node hover while joining

This commit is contained in:
Nick O'Leary 2018-12-18 21:45:33 +00:00
parent 33dade0584
commit 8502cf8498
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -2033,8 +2033,9 @@ RED.view = (function() {
return; return;
} }
var direction = d._def? (d.inputs > 0 ? 1: 0) : (d.direction == "in" ? 0: 1) var direction = d._def? (d.inputs > 0 ? 1: 0) : (d.direction == "in" ? 0: 1)
var wasJoining = false;
if (mouse_mode === RED.state.JOINING || mouse_mode === RED.state.QUICK_JOINING) { if (mouse_mode === RED.state.JOINING || mouse_mode === RED.state.QUICK_JOINING) {
wasJoining = true;
if (drag_lines.length > 0) { if (drag_lines.length > 0) {
if (drag_lines[0].virtualLink) { if (drag_lines[0].virtualLink) {
if (d.type === 'link in') { if (d.type === 'link in') {
@ -2045,7 +2046,11 @@ RED.view = (function() {
} }
} }
} }
portMouseUp(d, direction, 0); portMouseUp(d, direction, 0);
if (wasJoining) {
d3.selectAll(".port_hovered").classed("port_hovered",false);
}
} }
function nodeMouseDown(d) { function nodeMouseDown(d) {
@ -2499,6 +2504,19 @@ RED.view = (function() {
} }
},500); },500);
} }
} else if (mouse_mode === RED.state.JOINING || mouse_mode === RED.state.QUICK_JOINING) {
if (drag_lines.length > 0) {
var selectClass;
var portType;
if ((drag_lines[0].virtualLink && drag_lines[0].portType === PORT_TYPE_INPUT) || drag_lines[0].portType === PORT_TYPE_OUTPUT) {
selectClass = ".port_input .port";
portType = PORT_TYPE_INPUT;
} else {
selectClass = ".port_output .port";
portType = PORT_TYPE_OUTPUT;
}
portMouseOver(d3.select(this.parentNode).selectAll(selectClass),d,portType,0);
}
} }
}) })
.on("mouseout",function(d) { .on("mouseout",function(d) {
@ -2509,6 +2527,20 @@ RED.view = (function() {
portLabelHover.remove(); portLabelHover.remove();
portLabelHover = null; portLabelHover = null;
} }
if (mouse_mode === RED.state.JOINING || mouse_mode === RED.state.QUICK_JOINING) {
if (drag_lines.length > 0) {
var selectClass;
var portType;
if ((drag_lines[0].virtualLink && drag_lines[0].portType === PORT_TYPE_INPUT) || drag_lines[0].portType === PORT_TYPE_OUTPUT) {
selectClass = ".port_input .port";
portType = PORT_TYPE_INPUT;
} else {
selectClass = ".port_output .port";
portType = PORT_TYPE_OUTPUT;
}
portMouseOut(d3.select(this.parentNode).selectAll(selectClass),d,portType,0);
}
}
}); });
//node.append("rect").attr("class", "node-gradient-top").attr("rx", 6).attr("ry", 6).attr("height",30).attr("stroke","none").attr("fill","url(#gradient-top)").style("pointer-events","none"); //node.append("rect").attr("class", "node-gradient-top").attr("rx", 6).attr("ry", 6).attr("height",30).attr("stroke","none").attr("fill","url(#gradient-top)").style("pointer-events","none");