docs: use updateNodeInternals in teleport example

This commit is contained in:
bcakmakoglu
2022-06-16 23:00:31 +02:00
committed by Braks
parent 648350cded
commit 47bc652c46
2 changed files with 3 additions and 14 deletions
@@ -1,6 +1,5 @@
<script setup> <script setup>
import { Handle, Position } from '@braks/vue-flow' import { Handle, Position } from '@braks/vue-flow'
import { watch } from 'vue'
import { useTransition } from './useTransition.js' import { useTransition } from './useTransition.js'
const props = defineProps({ const props = defineProps({
@@ -8,17 +7,9 @@ const props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
nodeElement: {
type: Object,
required: false,
},
}) })
const { animation, transition, teleport, nodeElement, onClick } = useTransition(props.id, props.nodeElement) const { animation, transition, teleport, onClick } = useTransition(props.id)
watch(props, () => {
if (props.nodeElement) nodeElement.value = props.nodeElement
})
const changeAnimation = () => { const changeAnimation = () => {
animation.value = animation.value === 'fade' ? 'shrink' : 'fade' animation.value = animation.value === 'fade' ? 'shrink' : 'fade'
@@ -8,12 +8,11 @@ import { nextTick, ref } from 'vue'
* Otherwise edges do not connect properly * Otherwise edges do not connect properly
*/ */
export const useTransition = (id) => { export const useTransition = (id) => {
const nodeElement = ref()
const animation = ref('fade') const animation = ref('fade')
const transition = ref(false) const transition = ref(false)
const teleport = ref(null) const teleport = ref(null)
const { updateNodeDimensions, getNode, edges } = useVueFlow() const { updateNodeInternals, getNode, edges } = useVueFlow()
/** /**
* specify a selector to teleport to * specify a selector to teleport to
@@ -48,7 +47,7 @@ export const useTransition = (id) => {
setTimeout(() => { setTimeout(() => {
// if destination is null, defer hiding edges until node is teleported back // if destination is null, defer hiding edges until node is teleported back
if (!destination) { if (!destination) {
updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }]) updateNodeInternals([id])
nextTick(() => { nextTick(() => {
onFinish() onFinish()
@@ -103,7 +102,6 @@ export const useTransition = (id) => {
animation, animation,
transition, transition,
teleport, teleport,
nodeElement,
onClick, onClick,
} }
} }