feat(nodes,edges): Allow class or styles to be bound with function

* function param is current node
* makes it easier to add classes / styles if specific node is selected etc.
This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent 94e5bda77e
commit a50101bfd3
3 changed files with 18 additions and 6 deletions
+4 -1
View File
@@ -86,6 +86,9 @@ onMounted(() => {
store.updateNodeDimensions([{ id: node.value.id, nodeElement: nodeElement.value }])
})
const getClass = () => (node.value.class instanceof Function ? node.value.class(node.value) : node.value.class)
const getStyle = () => (node.value.style instanceof Function ? node.value.style(node.value) : node.value.style)
const scale = controlledComputed(
() => store.transform[2],
() => store.transform[2],
@@ -140,7 +143,7 @@ export default {
selected: node.selected,
selectable: props.selectable,
},
node.class,
getClass(),
]"
:style="{
zIndex: node.computedPosition.z,