Skip to content

Commit

Permalink
elyra-ai#1596 Use separate function to apply listeners to link handles (
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlyn authored Oct 14, 2023
1 parent 4d8dc5f commit 25cef13
Showing 1 changed file with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6411,27 +6411,12 @@ export default class SVGCanvasRenderer {
handlesGrp
.append(this.canvasLayout.linkStartHandleObject)
.attr("class", (d) => "d3-link-handle-start")
// Use mouse down instead of click because it gets called before drag start.
.on("mousedown", (d3Event, d) => {
this.logger.log("Link start handle - mouse down");
if (!this.config.enableDragWithoutSelect) {
this.selectObjectD3Event(d3Event, d, "link");
}
this.logger.log("Link end handle - finished mouse down");
});
.call(this.attachStartHandleListeners.bind(this));

handlesGrp
.append(this.canvasLayout.linkEndHandleObject)
.attr("class", (d) => "d3-link-handle-end")
// Use mouse down instead of click because it gets called before drag start.
.on("mousedown", (d3Event, d) => {
this.logger.log("Link end handle - mouse down");
if (!this.config.enableDragWithoutSelect) {
this.selectObjectD3Event(d3Event, d, "link");
}
this.logger.log("Link end handle - finished mouse down");
});

.call(this.attachEndHandleListeners.bind(this));
}

// Updates the start and end link handles for the handle groups passed in.
Expand Down Expand Up @@ -6494,6 +6479,32 @@ export default class SVGCanvasRenderer {
}
}

// Attaches any required event listeners to the start handles of the links.
attachStartHandleListeners(startHandles) {
startHandles
// Use mouse down instead of click because it gets called before drag start.
.on("mousedown", (d3Event, d) => {
this.logger.log("Link start handle - mouse down");
if (!this.config.enableDragWithoutSelect) {
this.selectObjectD3Event(d3Event, d, "link");
}
this.logger.log("Link end handle - finished mouse down");
});
}

// Attaches any required event listeners to the end handles of the links.
attachEndHandleListeners(endHandles) {
endHandles
// Use mouse down instead of click because it gets called before drag start.
.on("mousedown", (d3Event, d) => {
this.logger.log("Link end handle - mouse down");
if (!this.config.enableDragWithoutSelect) {
this.selectObjectD3Event(d3Event, d, "link");
}
this.logger.log("Link end handle - finished mouse down");
});
}

// Sets the custom inline styles on the link object passed in.
setLinkLineStyles(linkObj, link, type) {
const style = CanvasUtils.getObjectStyle(link, "line", type);
Expand Down

0 comments on commit 25cef13

Please sign in to comment.