Compare commits
2 Commits
f7d5f40c0f
...
e41869a9e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e41869a9e7 | ||
|
|
03fe8696ec |
25
bzGraflow.js
25
bzGraflow.js
@@ -88,16 +88,15 @@ class BZgraflow extends Buildoz{
|
|||||||
if(this.getBZAttribute('edit')){
|
if(this.getBZAttribute('edit')){
|
||||||
const edit = this.getBZAttribute('edit').split(',')
|
const edit = this.getBZAttribute('edit').split(',')
|
||||||
if(edit.includes('nodesmove')){
|
if(edit.includes('nodesmove')){
|
||||||
this.nodesMover = new MovingNodes(this)
|
this.nodesMover = new MovingNodes(this, '.bzgf-node')
|
||||||
this.nodesMover.enableMovingNodes('.bzgf-node')
|
|
||||||
}
|
}
|
||||||
if(edit.includes('wires')){
|
if(edit.includes('wires')){
|
||||||
this.WiresEditor = new EditWires(this)
|
this.WiresEditor = new EditWires(this, '.bzgf-wire')
|
||||||
this.WiresEditor.enableEditWires()
|
this.WiresEditor.enableEditWires()
|
||||||
//this.WiresEditor.enableMovingNodes('.bzgf-wire')
|
//this.WiresEditor.enableMovingNodes('.bzgf-wire')
|
||||||
}
|
}
|
||||||
if(edit.includes('dropnodes')){
|
if(edit.includes('dropnodes')){
|
||||||
this.NodesReceiver = new DroppingNodes(this)
|
this.NodesReceiver = new DroppingNodes(this, '.bzgf-node')
|
||||||
//this.NodesReceiver.enableDroppingNodes('.bzgf-node')
|
//this.NodesReceiver.enableDroppingNodes('.bzgf-node')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,7 +435,7 @@ class BZgraflow extends Buildoz{
|
|||||||
for(const node of this.flow.nodes){
|
for(const node of this.flow.nodes){
|
||||||
if((!node.coords) || (!node.coords.x) ||(!node.coords.y)) forceAutoplace=true
|
if((!node.coords) || (!node.coords.x) ||(!node.coords.y)) forceAutoplace=true
|
||||||
this.addNode(node)
|
this.addNode(node)
|
||||||
}
|
}
|
||||||
for(const link of this.flow.links){
|
for(const link of this.flow.links){
|
||||||
this.addWire(link)
|
this.addWire(link)
|
||||||
}
|
}
|
||||||
@@ -446,6 +445,11 @@ class BZgraflow extends Buildoz{
|
|||||||
else this.currentOrientation = 'vertical'
|
else this.currentOrientation = 'vertical'
|
||||||
}
|
}
|
||||||
if(forceAutoplace) this.autoPlace(this.currentOrientation)
|
if(forceAutoplace) this.autoPlace(this.currentOrientation)
|
||||||
|
this.dispatchEvent(new CustomEvent('refreshed', {
|
||||||
|
detail: { },
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert viewport (client) coordinates to this instance's SVG local coordinates.
|
// Convert viewport (client) coordinates to this instance's SVG local coordinates.
|
||||||
@@ -1172,8 +1176,10 @@ class BZgraflow extends Buildoz{
|
|||||||
Buildoz.define('graflow', BZgraflow)
|
Buildoz.define('graflow', BZgraflow)
|
||||||
|
|
||||||
class MovingNodes{
|
class MovingNodes{
|
||||||
constructor(graflow){
|
constructor(graflow, itemSelector, handleSelector = itemSelector){
|
||||||
this.graflow = graflow
|
this.graflow = graflow
|
||||||
|
this.itemSelector = itemSelector
|
||||||
|
this.handleSelector = handleSelector
|
||||||
this.nodesContainer = this.graflow.mainContainer.querySelector('.bzgf-nodes-container')
|
this.nodesContainer = this.graflow.mainContainer.querySelector('.bzgf-nodes-container')
|
||||||
this.state = null
|
this.state = null
|
||||||
|
|
||||||
@@ -1184,14 +1190,13 @@ class MovingNodes{
|
|||||||
button,
|
button,
|
||||||
a[href]
|
a[href]
|
||||||
`
|
`
|
||||||
|
this.graflow.addEventListener('refreshed', this.enableMovingNodes.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
enableMovingNodes(itemSelector, handleSelector = itemSelector) {
|
enableMovingNodes() {
|
||||||
this.itemSelector = itemSelector
|
|
||||||
this.handleSelector = handleSelector
|
|
||||||
if(!this._handleCursorStyle){
|
if(!this._handleCursorStyle){
|
||||||
const style = document.createElement('style')
|
const style = document.createElement('style')
|
||||||
style.textContent = `${handleSelector}{ cursor: move }`
|
style.textContent = `${this.handleSelector}{ cursor: move }`
|
||||||
this.nodesContainer.appendChild(style)
|
this.nodesContainer.appendChild(style)
|
||||||
this._handleCursorStyle = style
|
this._handleCursorStyle = style
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user