jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.78k stars 741 forks source link

can't access vuex in a registered vue component #302

Closed AnoOnion closed 2 years ago

AnoOnion commented 2 years ago

i want to access the getters function in the component that i have registered, but i get an error like :

error

do you have a solution? thanks

jerosoler commented 2 years ago

How are you mounting drawflow?

And the node?

Vue2 or Vue3?

AnoOnion commented 2 years ago
           onMounted(() => {
                     let layout      = document.getElementById('tracking-flow')

                     editor.value    = new Drawflow(layout, vue, instance.appContext.app._context)
                     editor.reroute  = true

                     editor.start()

                     editor.registerNode('branchnode', BranchNode)

                     editor.addNode('main-address', 0, 1, 0, 190, 'branch-node', { 'data': 'test' }, 'branchnode', 'vue')
           })

is it correct to use dragflow ? i use vue 3

jerosoler commented 2 years ago

I understand that vuex is added to the instance.

You can see an example of vue3 https://github.com/jerosoler/drawflow-vue3-example

View app component: https://github.com/jerosoler/drawflow-vue3-example/blob/master/src/components/drawflow.vue

And Node component: https://github.com/jerosoler/drawflow-vue3-example/blob/master/src/components/nodes/node1.vue

Gettin the instance:

df = getCurrentInstance().appContext.config.globalProperties.$df.value;
AnoOnion commented 2 years ago

wow, it worked 💯

ooh, one more thing, when I create a node with a height of 100px and when that node is selected then the height will change to 200px

but the connection position does not adjust, how so that when the height of the selected node changes, the connection position adjusts accordingly?

thanks for seeing this before

jerosoler commented 2 years ago

Force update connections with:

updateConnectionNodes('node-'+id);
AnoOnion commented 2 years ago

Thank you very much, i will try it tomorrow 👍