Linker is Node Editor Library, I built this library for a new project I'm working on, besides I was interested in building one.
Note: This is a beta
version.
<script src="https://code.jquery.com/jquery-3.2.0.min.js"></script>
<script src="linker.min.js"></script>
<link rel="stylesheet" href="linker.min.css">
<div id="linker"></div>
$(document).ready(function () {
var linker = $('#linker').linker();
});
You can download the demo files from dist folder
var node = linker.node({id: 'first', name: 'First Node', x: 100, y: 100});
You can pass any data as a node and read it from the events handler
var node_in = node.input('input_id', 'Input Name');
You can add multiple inputs
var node_out = node.output('output_id', 'Output Name');
You can add multiple outputs
node_out.connect(node2_in);
You can connect the output to multiple inputs
node_out.connect(node2_in, true);
node.onDrag = function (x, y) {
console.log(x, y, this);
// 'x, y' is the new position
// 'this' is the node object
};
node.onDragFinish = function (x, y) {
console.log(x, y, this);
// 'x, y' is the new position
// 'this' is the node object
};
node.onRemove = function () {
console.log(this);
};
node.onSetting = function () {
alert('Setting ' + this.name);
};
node_out.onConnect = function (input) {
console.log(this, input);
// 'this' is the output object
// 'this.node' is the output parent node object
// '$(this.el)' is the output DOM element
// 'input' is the input object
// 'input.node' is the output parent node object
// '$(input.el)' is the input DOM element
};
node_out.onRemove = function (index) {
console.log(index)
};
var linker = $('#linker').linker({
// hide setting icons from the nodes
settingIcon: false
});
$(document).ready(function () {
var linker = $('#linker').linker();
// add a node
var node1 = linker.node({id: 'first', name: 'First Node', x: 100, y: 100});
// when the node position change
node1.onDrag = function (x, y) {
console.log(x, y, this); // print the new position and the node object
};
// trigger when delete the node
node1.onRemove = function () {
console.log(this); // print the node object
};
// trigger when setting icon clicked
node1.onSetting = function () {
alert('Setting ' + this.name);
};
// add an input
node1.input('input_id', 'Input Name');
// add an output
var node1_out = node1.output('output_id', 'Output Name');
// trigger when this output connect to new input
node1_out.onConnect = function (input) {
console.log(this, input); // print the output and the input objects
};
// trigger when this output link remove
node1_out.onRemove = function (index) {
console.log(index)
};
// add node 2
var node2 = linker.node({id: 'second', name: 'Second Node', x: 400, y: 200});
var node2_in = node2.input('input_id', 'Input Name');
node2.onSetting = function () {
alert('Setting ' + this.name);
};
// add path between two nodes
node1_out.connect(node2_in);
});
nmp install
to install required modules
gulp watch
to compile sass and javascript files
Linker is inspired by NEditorJS
MIT