Skip to content

Commit

Permalink
#1997 Apply class to objects being moved by dragging (#1998)
Browse files Browse the repository at this point in the history
Signed-off-by: CTomlyn <[email protected]>
  • Loading branch information
tomlyn authored May 31, 2024
1 parent e1705cd commit f825b44
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ export default class SVGCanvasUtilsDragObjects {
if (this.draggingObjectData.dragObjects?.length > 0) {
this.draggingObjectData.dragStartX = this.draggingObjectData.dragObjects[0].x_pos;
this.draggingObjectData.dragStartY = this.draggingObjectData.dragObjects[0].y_pos;

// Apply the 'd3-is-moving' class to the objects being dragged.
this.switchIsMovingClass(this.draggingObjectData.dragObjects, true);
}

// If we are dragging an 'insertable' node, set it to be translucent so
Expand Down Expand Up @@ -654,7 +657,6 @@ export default class SVGCanvasUtilsDragObjects {
this.ren.displaySVGToFitSupernode();
}


if (this.existingNodeInsertableIntoLink) {
const link = this.ren.getLinkAtMousePos(d3Event.sourceEvent.clientX, d3Event.sourceEvent.clientY);
// Set highlighting when there is no link because this will turn
Expand Down Expand Up @@ -698,6 +700,9 @@ export default class SVGCanvasUtilsDragObjects {
clearTimeout(this.startNodeInsertingInLink);
clearTimeout(this.startNodeAttachingToDetachedLinks);

// Remove the 'd3-is-moving' class from the objects being dragged.
this.switchIsMovingClass(draggingObjectData.dragObjects, false);

// If the pointer hasn't moved and enableDragWithoutSelect is enabled we interpret
// that as a select on the object.
if (draggingObjectData.dragOffsetX === 0 &&
Expand Down Expand Up @@ -776,6 +781,18 @@ export default class SVGCanvasUtilsDragObjects {
return selectedObjects;
}

// Switches the 'd3-is-moving' class on and off for the objects currently
// being dragged, based on the state passed in.
switchIsMovingClass(dragObjects, state) {
dragObjects.forEach((obj) => {
if (CanvasUtils.isNode(obj)) {
this.ren.getNodeGroupSelectionById(obj.id).classed("d3-is-moving", state);
} else {
this.ren.getCommentGroupSelectionById(obj.id).classed("d3-is-monving", state);
}
});
}

// Returns true if the current drag objects array has a single node which
// is 'insertable' into a data link between nodes on the canvas. Returns
// false otherwise, including if a single comment is being dragged.
Expand Down

0 comments on commit f825b44

Please sign in to comment.