diff --git a/examples/Stress/StressExample.vue b/examples/Stress/StressExample.vue index 68d24c35..66675ebf 100644 --- a/examples/Stress/StressExample.vue +++ b/examples/Stress/StressExample.vue @@ -51,7 +51,7 @@ const updateElements = () => { + diff --git a/src/components/Loading/LoadingIndicator.vue b/src/components/Loading/LoadingIndicator.vue new file mode 100644 index 00000000..9dcefbea --- /dev/null +++ b/src/components/Loading/LoadingIndicator.vue @@ -0,0 +1,18 @@ + + diff --git a/src/container/VueFlow/VueFlow.vue b/src/container/VueFlow/VueFlow.vue index 07dcb792..f1bf220a 100644 --- a/src/container/VueFlow/VueFlow.vue +++ b/src/container/VueFlow/VueFlow.vue @@ -16,11 +16,13 @@ import { FlowStore, FlowState, FlowInstance, + Loading, } from '../../types' -import ZoomPane from '../../container/ZoomPane/ZoomPane.vue' -import SelectionPane from '../../container/SelectionPane/SelectionPane.vue' -import NodeRenderer from '../../container/NodeRenderer/NodeRenderer.vue' -import EdgeRenderer from '../../container/EdgeRenderer/EdgeRenderer.vue' +import ZoomPane from '../ZoomPane/ZoomPane.vue' +import SelectionPane from '../SelectionPane/SelectionPane.vue' +import NodeRenderer from '../NodeRenderer/NodeRenderer.vue' +import EdgeRenderer from '../EdgeRenderer/EdgeRenderer.vue' +import LoadingIndicator from '../../components/Loading/LoadingIndicator.vue' import { createHooks, initFlow, useZoomPanHelper } from '../../composables' import { onLoadGetElements, onLoadProject, onLoadToObject } from '../../utils' @@ -62,7 +64,7 @@ export interface FlowProps extends Partial { zoomOnDoubleClick?: boolean edgeUpdaterRadius?: number storageKey?: string - showLoadingIndicator?: boolean + loading?: Loading } const emit = defineEmits([...Object.keys(createHooks()), 'update:elements', 'update:modelValue']) @@ -104,7 +106,7 @@ const props = withDefaults(defineProps(), { panOnScrollMode: PanOnScrollMode.Free, paneMoveable: true, edgeUpdaterRadius: 10, - showLoadingIndicator: false, + loading: false, }) const store = initFlow(emit, typeof props.storageKey === 'string' ? props.storageKey : props.id, props.store) const elements = useVModel(props, props.elements.length ? 'elements' : 'modelValue', emit) @@ -169,57 +171,89 @@ invoke(async () => { store.hooks.load.trigger(instance) store.instance = instance }) + +const transitionName = computed(() => { + let name = '' + if (typeof store.loading === 'object' && store.loading.transition) { + if (typeof store.loading.transition === 'string') name = store.loading.transition + else name = store.loading.transition.name + } + return name +}) + +const transitionMode = computed(() => { + let mode = '' + if (typeof store.loading === 'object' && store.loading.transition) { + if (typeof store.loading.transition !== 'string') mode = store.loading.transition.mode + } + return mode +})