center to origin node in LibraryTree

This commit is contained in:
axolotle
2021-07-28 18:03:36 +02:00
parent 985f5d6e88
commit 759fbd94f1
2 changed files with 20 additions and 4 deletions
+11 -2
View File
@@ -1,6 +1,10 @@
<template>
<b-overlay :show="nodeTree.nodes.length === 0" class="h-100" z-index="0">
<map-zoom id="library-tree" :min-zoom="0.3" :max-zoom="1">
<map-zoom
id="library-tree"
:min-zoom="0.3" :max-zoom="1" :center="center"
:key="nodeDepartId"
>
<path
v-for="link in nodeTree.links"
:key="`${link.source.data.id}_${link.target.data.id}`"
@@ -77,7 +81,7 @@ export default {
},
computed: {
...mapGetters(['nodeTree']),
...mapGetters(['nodeDepartId', 'nodeTree']),
dataNodes () {
return this.nodeTree.nodes.map(node => node.data)
@@ -100,6 +104,11 @@ export default {
.force('y', forceY())
},
center () {
const { x, y } = this.nodeTree.nodes.length ? this.nodeTree.nodes[0] : { x: 0, y: 0 }
return { x, y }
},
// ONE TIME GETTER
lineGenerator () {
return line().x(node => node.x).y(node => node.y)