|
@@ -9,7 +9,7 @@
|
|
|
// import jsPlumb from 'jsplumb'
|
|
|
import Vue from 'vue'
|
|
|
import Node from './modules/Node.vue'
|
|
|
-import { ready, newInstance, EVENT_CONNECTION, EVENT_CONNECTION_DBL_CLICK } from '@jsplumb/browser-ui'
|
|
|
+import { ready, newInstance, EVENT_CONNECTION, EVENT_CONNECTION_DBL_CLICK, EVENT_DRAG_STOP } from '@jsplumb/browser-ui'
|
|
|
export default {
|
|
|
components: {
|
|
|
Node,
|
|
@@ -21,12 +21,28 @@ export default {
|
|
|
details: [
|
|
|
{
|
|
|
name: 'node1',
|
|
|
+ x: 400,
|
|
|
+ y: 40,
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ name: 'node2',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'node3',
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
{
|
|
|
+ x: 100,
|
|
|
+ y: 320,
|
|
|
name: 'node2',
|
|
|
+ children: [],
|
|
|
},
|
|
|
{
|
|
|
+ x: 660,
|
|
|
+ y: 320,
|
|
|
name: 'node3',
|
|
|
+ children: [],
|
|
|
},
|
|
|
],
|
|
|
}
|
|
@@ -47,7 +63,6 @@ export default {
|
|
|
grid: { w: 20, h: 20 },
|
|
|
},
|
|
|
})
|
|
|
- console.log()
|
|
|
instance.importDefaults({
|
|
|
anchor: 'Continuous',
|
|
|
connectionsDetachable: false,
|
|
@@ -87,7 +102,6 @@ export default {
|
|
|
})
|
|
|
instance.addSourceSelector('.bottom')
|
|
|
instance.addTargetSelector('.top')
|
|
|
- console.log(this.$refs)
|
|
|
this.$refs.node.forEach((item) => {
|
|
|
instance.addEndpoint(item.$el, { target: true, source: true })
|
|
|
})
|
|
@@ -117,6 +131,11 @@ export default {
|
|
|
// { type: 'Arrow', options: { location: 1 } },
|
|
|
// ],
|
|
|
// })
|
|
|
+ instance.bind(EVENT_DRAG_STOP, (val) => {
|
|
|
+ console.log(val.el.__vue__)
|
|
|
+ console.log(3)
|
|
|
+ val.el.__vue__.setPosition(val.elements[0].pos)
|
|
|
+ })
|
|
|
// 建立链接
|
|
|
instance.bind(EVENT_CONNECTION, (val) => {
|
|
|
console.log(val)
|