
Security News
Node.js TSC Votes to Stop Distributing Corepack
Corepack will be phased out from future Node.js releases following a TSC vote.
cytoscape-compound-drag-and-drop
Advanced tools
Drag-and-drop UI for creating and editing the children of compound parent nodes
Compound node drag-and-drop UI for adding and removing children (demo)
Download the library:
npm install cytoscape-compound-drag-and-drop
,bower install cytoscape-compound-drag-and-drop
, orImport the library as appropriate for your project:
ES import:
import cytoscape from 'cytoscape';
import compoundDragAndDrop from 'cytoscape-compound-drag-and-drop';
cytoscape.use( compoundDragAndDrop );
CommonJS require:
let cytoscape = require('cytoscape');
let compoundDragAndDrop = require('cytoscape-compound-drag-and-drop');
cytoscape.use( compoundDragAndDrop ); // register extension
AMD:
require(['cytoscape', 'cytoscape-compound-drag-and-drop'], function( cytoscape, compoundDragAndDrop ){
compoundDragAndDrop( cytoscape ); // register extension
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
true
return value for options.grabbedNode(node)
.true
return value for options.dropTarget(node)
.options.newParentNode(grabbedNode, dropSibling)
. The grabbed node and drop sibling are made to be children of the newly created drop target.
true
return value for options.dropSibling(node)
.Create an instance of the drag-and-drop UI:
const cdnd = cy.compoundDragAndDrop(options);
The options
object is outlined below with the default values:
const options = {
grabbedNode: node => true, // filter function to specify which nodes are valid to grab and drop into other nodes
dropTarget: (dropTarget, grabbedNode) => true, // filter function to specify which parent nodes are valid drop targets
dropSibling: (dropSibling, grabbedNode) => true, // filter function to specify which orphan nodes are valid drop siblings
newParentNode: (grabbedNode, dropSibling) => ({}), // specifies element json for parent nodes added by dropping an orphan node on another orphan (a drop sibling). You can chose to return the dropSibling in which case it becomes the parent node and will be preserved after all its children are removed.
boundingBoxOptions: { // same as https://js.cytoscape.org/#eles.boundingBox, used when calculating if one node is dragged over another
includeOverlays: false,
includeLabels: true
},
overThreshold: 10, // make dragging over a drop target easier by expanding the hit area by this amount on all sides
outThreshold: 10 // make dragging out of a drop target a bit harder by expanding the hit area by this amount on all sides
};
There are a number of functions available on the cdnd
object:
cdnd.disable(); // disables the UI
cdnd.enable(); // re-enables the UI
cdnd.destroy(); // removes the UI
These events are emitted by the extension during its gesture cycle.
cdndgrab
: Emitted on a grabbed node that is compatible with the drag-and-drop gesture.
grabbedNode.on('cdndgrab', (event) => {})
cdndover
: Emitted on a grabbed node when it is dragged over another node.
grabbedNode.on('cdndover', (event, dropTarget, dropSibling) => {})
cdndout
: Emmitted on a grabbed node when it is dragged out of its parent.
grabbedNode.on('cdndout', (event, dropTarget, dropSibling) => {})
cdnddrop
: Emitted on a grabbed node when it is dropped (freed).
droppedNode.on('cdnddrop', (event, dropTarget, dropSibling) => {})
For these events:
dropTarget
is always the parent node under consideration.dropSibling
is nonempty only if the grabbed node was originally dragged over the drop sibling.These classes are applied to nodes during the gesture cycle. You can use them in your stylesheet to customise the look of the nodes during different phases of the gesture.
cdnd-grabbed-node
: Applied to the grabbed node, until it is dropped.cdnd-drop-target
: Applied to a drop target node, while the grabbed node is over it.cdnd-drop-sibling
: Applied to drop sibling node, while the grabbed node is over its drop target (parent).cdnd-new-parent
: Applied to a parent node that has been created after dragging a node over. This class will not be present if the parent node is the dropSibling - see the newParentNode
callback function.npm run build
: Build ./src/**
into cytoscape-compound-drag-and-drop.js
npm run watch
: Automatically build on changes with live reloading (N.b. you must already have an HTTP server running)npm run lint
: Run eslint on the sourceN.b. all builds use babel, so modern ES features can be used in the src
.
This project is set up to automatically be published to npm and bower. To publish:
npm run build:release
git commit -am "Build for release"
npm version major|minor|patch
git push && git push --tags
npm publish .
bower register cytoscape-compound-drag-and-drop https://github.com/cytoscape/cytoscape.js-compound-drag-and-drop.git
FAQs
Drag-and-drop UI for creating and editing the children of compound parent nodes
The npm package cytoscape-compound-drag-and-drop receives a total of 6,337 weekly downloads. As such, cytoscape-compound-drag-and-drop popularity was classified as popular.
We found that cytoscape-compound-drag-and-drop demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.
Security News
Oxlint's beta release introduces 500+ built-in linting rules while delivering twice the speed of previous versions, with future support planned for custom plugins and improved IDE integration.