File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @vue-flow/core " : patch
3
+ ---
4
+
5
+ Hide viewport until initial fit view is finished
Original file line number Diff line number Diff line change 1
1
<script lang="ts" setup>
2
+ import { computed } from ' vue'
2
3
import { useVueFlow } from ' ../../composables'
3
4
4
- const { viewport } = useVueFlow ()
5
+ const { viewport, fitViewOnInit, fitViewOnInitDone } = useVueFlow ()
6
+
7
+ const isHidden = computed (() => {
8
+ if (fitViewOnInit .value ) {
9
+ return ! fitViewOnInitDone .value
10
+ }
11
+
12
+ return false
13
+ })
14
+
15
+ const transform = computed (() => ` translate(${viewport .value .x }px,${viewport .value .y }px) scale(${viewport .value .zoom }) ` )
5
16
</script >
6
17
7
18
<script lang="ts">
@@ -12,10 +23,7 @@ export default {
12
23
</script >
13
24
14
25
<template >
15
- <div
16
- class =" vue-flow__transformationpane vue-flow__container"
17
- :style =" { transform: `translate(${viewport.x}px,${viewport.y}px) scale(${viewport.zoom})` }"
18
- >
26
+ <div class =" vue-flow__transformationpane vue-flow__container" :style =" { transform, opacity: isHidden ? 0 : undefined }" >
19
27
<slot />
20
28
</div >
21
29
</template >
Original file line number Diff line number Diff line change @@ -173,8 +173,9 @@ export function useActions(
173
173
}
174
174
175
175
if ( ! state . fitViewOnInitDone && state . fitViewOnInit ) {
176
- viewportHelper . value . fitView ( )
177
- state . fitViewOnInitDone = true
176
+ viewportHelper . value . fitView ( ) . then ( ( ) => {
177
+ state . fitViewOnInitDone = true
178
+ } )
178
179
}
179
180
180
181
if ( changes . length ) {
You can’t perform that action at this time.
0 commit comments