fix: remove waiting for node dimensions in transformation pane

* Fixes node dimensions having 0 values when paneReady is fired
This commit is contained in:
Braks
2022-04-11 11:30:10 +02:00
parent 07ee6eddf7
commit ca2a72c3a8
2 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ const DEFAULT_PADDING = 0.1
const transition = (selection: D3Selection, ms = 0) => selection.transition().duration(ms)
export const untilDimensions = async (store: Store) => {
const untilDimensions = async (store: Store) => {
// if ssr we can't wait for dimensions, they'll never really exist
const window = useWindow()
if ('screen' in window) {
+13 -2
View File
@@ -1,12 +1,23 @@
<script lang="ts" setup>
import NodeRenderer from '../NodeRenderer/NodeRenderer.vue'
import EdgeRenderer from '../EdgeRenderer/EdgeRenderer.vue'
import { useVueFlow, useZoomPanHelper, untilDimensions } from '../../composables'
import { FlowInstance } from '../../types'
import { useVueFlow, useZoomPanHelper, useWindow } from '../../composables'
import { FlowInstance, Store } from '../../types'
import { onLoadGetEdges, onLoadGetElements, onLoadGetNodes, onLoadProject, onLoadToObject } from '../../utils'
const { id, store } = useVueFlow()
const untilDimensions = async (store: Store) => {
// if ssr we can't wait for dimensions, they'll never really exist
const window = useWindow()
if ('screen' in window) {
// wait until viewport dimensions has been established
await until(store.dimensions).toMatch(({ height, width }) => !isNaN(width) && width > 0 && !isNaN(height) && height > 0)
}
return true
}
const ready = ref(false)
onMounted(async () => {
const { zoomIn, zoomOut, zoomTo, setTransform, getTransform, fitView, fitBounds, setCenter } = useZoomPanHelper(store)