fix: skip dimensions check when ssr
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,7 @@ import SelectionPane from '../SelectionPane/SelectionPane.vue'
|
|||||||
import NodeRenderer from '../NodeRenderer/NodeRenderer.vue'
|
import NodeRenderer from '../NodeRenderer/NodeRenderer.vue'
|
||||||
import EdgeRenderer from '../EdgeRenderer/EdgeRenderer.vue'
|
import EdgeRenderer from '../EdgeRenderer/EdgeRenderer.vue'
|
||||||
import LoadingIndicator from '../../components/Loading/LoadingIndicator.vue'
|
import LoadingIndicator from '../../components/Loading/LoadingIndicator.vue'
|
||||||
import { createHooks, initFlow, useZoomPanHelper } from '../../composables'
|
import { createHooks, initFlow, useWindow, useZoomPanHelper } from '../../composables'
|
||||||
import { onLoadGetElements, onLoadProject, onLoadToObject } from '../../utils'
|
import { onLoadGetElements, onLoadProject, onLoadToObject } from '../../utils'
|
||||||
|
|
||||||
interface FlowProps {
|
interface FlowProps {
|
||||||
@@ -137,9 +137,12 @@ invoke(async () => {
|
|||||||
await store.setElements(elements.value)
|
await store.setElements(elements.value)
|
||||||
store.isReady = true
|
store.isReady = true
|
||||||
|
|
||||||
await until(store.dimensions).toMatch(({ height, width }) => !isNaN(width) && width > 0 && !isNaN(height) && height > 0)
|
// if ssr we can't wait for dimensions, they'll never really exist
|
||||||
const { zoomIn, zoomOut, zoomTo, transform: setTransform, fitView } = useZoomPanHelper(store)
|
const window = useWindow()
|
||||||
|
if ('screen' in window)
|
||||||
|
await until(store.dimensions).toMatch(({ height, width }) => !isNaN(width) && width > 0 && !isNaN(height) && height > 0)
|
||||||
|
|
||||||
|
const { zoomIn, zoomOut, zoomTo, transform: setTransform, fitView } = useZoomPanHelper(store)
|
||||||
const instance: FlowInstance = {
|
const instance: FlowInstance = {
|
||||||
fitView: (params = { padding: 0.1 }) => fitView(params),
|
fitView: (params = { padding: 0.1 }) => fitView(params),
|
||||||
zoomIn,
|
zoomIn,
|
||||||
@@ -174,11 +177,6 @@ const transitionName = computed(() => {
|
|||||||
return name
|
return name
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts">
|
|
||||||
export default {
|
|
||||||
name: 'VueFlow',
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<template>
|
<template>
|
||||||
<div class="vue-flow">
|
<div class="vue-flow">
|
||||||
<Transition key="vue-flow-transition" :name="transitionName">
|
<Transition key="vue-flow-transition" :name="transitionName">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { D3ZoomEvent, zoom, zoomIdentity, ZoomTransform } from 'd3-zoom'
|
|||||||
import { get, invoke } from '@vueuse/core'
|
import { get, invoke } from '@vueuse/core'
|
||||||
import { pointer, select } from 'd3-selection'
|
import { pointer, select } from 'd3-selection'
|
||||||
import { FlowTransform, KeyCode, PanOnScrollMode } from '../../types'
|
import { FlowTransform, KeyCode, PanOnScrollMode } from '../../types'
|
||||||
import { useKeyPress, useStore } from '../../composables'
|
import { useKeyPress, useStore, useWindow } from '../../composables'
|
||||||
import { clamp } from '../../utils'
|
import { clamp } from '../../utils'
|
||||||
|
|
||||||
interface ZoomPaneProps {
|
interface ZoomPaneProps {
|
||||||
@@ -182,7 +182,8 @@ store.dimensions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip waiting for ssr
|
// skip waiting for ssr
|
||||||
if (typeof window !== 'undefined') await until(() => store.isReady).toMatch((y) => y)
|
const window = useWindow()
|
||||||
|
if ('screen' in window) await until(() => store.isReady).toMatch((y) => y)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[width, height],
|
[width, height],
|
||||||
|
|||||||
Reference in New Issue
Block a user