chore(core): cleanup (#1003)

This commit is contained in:
Braks
2023-07-10 19:20:26 +02:00
parent 61f8a68b84
commit 55de815a39
3 changed files with 16 additions and 9 deletions
+10 -3
View File
@@ -28,7 +28,7 @@ export function useViewport(state: State, getters: ComputedGetters) {
const { nodes, d3Zoom, d3Selection, dimensions, translateExtent, minZoom, maxZoom, viewport, snapToGrid, snapGrid, hooks } =
$(state)
const { getNodes } = $(getters)
const { getNodes } = getters
const nodesInitialized = ref(false)
@@ -36,7 +36,14 @@ export function useViewport(state: State, getters: ComputedGetters) {
nodesInitialized.value = true
})
const isReady = computed(() => !!d3Zoom && !!d3Selection && !!dimensions.width && !!dimensions.height && nodesInitialized.value)
const isReady = computed(
() =>
!!d3Zoom &&
!!d3Selection &&
!!dimensions.width &&
!!dimensions.height &&
(getNodes.value.length ? nodesInitialized.value : true),
)
function zoom(scale: number, duration?: number) {
if (d3Selection && d3Zoom) {
@@ -89,7 +96,7 @@ export function useViewport(state: State, getters: ComputedGetters) {
return
}
const nodesToFit: GraphNode[] = (options.includeHiddenNodes ? nodes : getNodes).filter((node) => {
const nodesToFit: GraphNode[] = (options.includeHiddenNodes ? nodes : getNodes.value).filter((node) => {
const initialized = node.initialized && node.dimensions.width && node.dimensions.height
let shouldInclude = true