Skip to content

expose "onMoveNode" method (optional), added "canDragNode" method (optional), center svg icons in control buttons - #280

Open
man-person wants to merge 4 commits into
uber:masterfrom
man-person:master
Open

expose "onMoveNode" method (optional), added "canDragNode" method (optional), center svg icons in control buttons#280
man-person wants to merge 4 commits into
uber:masterfrom
man-person:master

Conversation

@man-person

@man-personman-person commented Oct 11, 2020

Copy link
Copy Markdown

needed to do some stuff while dragging a node so i added these.

may be relevant to issues: #281#261#195

@CLAassistant

CLAassistant commented Oct 11, 2020

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

added "canDragNode" method (optional)
@man-personman-person changed the title center svg icon in re-center control buttonexpose "onMoveNode" method (optional), added "canDragNode" method (optional), center svg icons in control buttonsOct 22, 2020
@man-person

Copy link
Copy Markdown
Author

@9renpoto@ksnyder9801 I’d be grateful if you could review this one

@@ -77,6 +78,7 @@ export type IGraphViewProps = {
onSwapEdge?: (sourceNode: INode, targetNode: INode, edge: IEdge) => void,
onUndo?: () => void,
onUpdateNode?: (node: INode) => void,

@ajboghajboghNov 16, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onUpdateNode should already tell you that the node moved. It passes the new X,Y coordinates within the INode type. Is it possible to call onUpdateNode instead of creating a new onMoveNode method?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem with this is that onUpdateNode is only called when the move is finished, not while the move is in progress. That is also why one can not just return false from onUpdateNode and thereby prevent movement.

hoveredNode: INode | null,
swapEdge: IEdge
) => boolean,
canDragNode?: (nodeId: string) => boolean,

@ajboghajboghNov 16, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to canMoveNode or canUpdateNode?

canSwapEdge: () => true,
canDeleteEdge: () => true,
canDeleteNode: () => true,
canDragNode: () => true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to canMoveNode

if (!shiftKey && !draggingEdge) {
if (onMoveNode) {
onMoveNode(node);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement needs to move within the if statement on line 809.

Comment threadsrc/styles/main.scss

> svg {
vertical-align: sub;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase on master. This may be fixed.

@ajboghajbogh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase on master and then comment to justify your reasoning and update the PR based on the conversation.

@ahoerethahoereth mentioned this pull request Jan 2, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@man-person@CLAassistant@ajbogh@9renpoto@ahoereth