Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Added new events for Control Node D&D #3771

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Added new events for Control Node D&D #3771

wants to merge 1 commit into from

Conversation

milvasic
Copy link

We need notification on control node dragging and drag end for Vis Network. We need this so we can introduce some constraints for connecting nodes, and we need to do that proactively by changing cursor to 'not-allowed' when connecting is not allowed.

To solve this we introduced two new events 'controlNodeDragging' and 'controlNodeDragEnd', that notify us about control node state. These events are generated inside _dragControlNode and _finishConnect functions respectively. With this implemented, we can now change cursor over control node by checking constraints at the moment when event occurs. This looks as in attached image.

image

network.on("controlNodeDragEnd", function (params) {
params.event = "[original event]";
document.getElementById('eventSpan').innerHTML = '<h2>control node drag end event:</h2>' + JSON.stringify(params, null, 4);
console.log('controlNodeDragEnd Event:', params);

Choose a reason for hiding this comment

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

when I visit the events/interactionEvents.html example to test this, and I drag a node then release it, I don't see the controlNodeDragEnd Event: logged out.

@vasa93 curious, could you tell me what I am missing? what do we need to test the functionality in this PR?

screen shot 2018-09-05 at 11 43 31 am

Choose a reason for hiding this comment

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

here are the testing steps I tried in list and gif form:

  1. visit example http://127.0.0.1:8080/examples/network/events/interactionEvents.html
  2. open browser console
  3. drag a node
  4. look for controlNodeDragEnd Event: in the browser console

vis-pr-3771-after

@milvasic
Copy link
Author

milvasic commented Sep 5, 2018

Actually, control node is node that is dragged when you are trying to connect two nodes with an edge. It's special node, and for this node I have introduced new events so we could know when user is dragging that particular node and when user ends dragging it.

So, you could try that, and if my help is needed after that, I can...help. :)

@micahstubbs
Copy link

awesome, thanks for teaching me what a control node is @vasa93 😄

I've give this a try:

connect two nodes with an edge

@micahstubbs
Copy link

micahstubbs commented Sep 5, 2018

ok, I see it now, looks good to me ✅

thanks for sharing the steps to test this one @vasa93

http://127.0.0.1:8080/examples/network/events/interactionEvents.html

vis-pr-3771-control-node-drag-1

@micahstubbs
Copy link

@micahstubbs
Copy link

I've merged this in the community standalone network module project, and published a minor version with this enhancement up to npm 🎉

visjs-community/visjs-network#34
https://www.npmjs.com/package/visjs-network

@mojoaxel
Copy link
Member

💌 Thanks @vasa93 for your contribution!
This pull-request has been merge into visjs/vis-network#23

@milvasic
Copy link
Author

It's been my pleasure. Vis is great library, and I'm glad you appreciate my contribution.

@mojoaxel mojoaxel added Network visjs APPLIED this PR was merged into a repo of the visjs family labels Jul 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Network visjs APPLIED this PR was merged into a repo of the visjs family
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants