diff --git a/examples/src/Basic/BasicOptionsAPI.vue b/examples/src/Basic/BasicOptionsAPI.vue index 08c11db2..2bb7227d 100644 --- a/examples/src/Basic/BasicOptionsAPI.vue +++ b/examples/src/Basic/BasicOptionsAPI.vue @@ -40,8 +40,9 @@ export default defineComponent({ onNodeDragStop(e: FlowEvents['nodeDragStop']) { console.log('drag stop', e) }, - onPaneReady({ fitView }: FlowEvents['paneReady']) { - fitView({ padding: 0.1 }) + onPaneReady(instance: FlowEvents['paneReady']) { + instance.fitView() + this.instance = instance }, onConnect(params: FlowEvents['connect']) { addEdge(params, this.elements) diff --git a/package/src/composables/useVueFlow.ts b/package/src/composables/useVueFlow.ts index 4e078d05..57bae96c 100644 --- a/package/src/composables/useVueFlow.ts +++ b/package/src/composables/useVueFlow.ts @@ -109,7 +109,8 @@ export default ( } if (!vueFlow) throw new Error('vue flow store instance not found.') - provide(VueFlow, vueFlow) + + if (scope) provide(VueFlow, vueFlow) return vueFlow }