chore(docs): avoid jumping intro
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { Handle, Position, VueFlow, useVueFlow } from '@vue-flow/core'
|
import { Handle, Position, VueFlow, useVueFlow } from '@vue-flow/core'
|
||||||
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
|
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
|
||||||
import { Background } from '@vue-flow/background'
|
import { Background } from '@vue-flow/background'
|
||||||
|
import { onBeforeUnmount } from 'vue'
|
||||||
import Heart from '~icons/mdi/heart'
|
import Heart from '~icons/mdi/heart'
|
||||||
|
|
||||||
const breakpoints = useBreakpoints(breakpointsTailwind)
|
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||||
@@ -56,7 +57,7 @@ const initialEdges = [
|
|||||||
style: { strokeWidth: 4, stroke: '#0ea5e9' },
|
style: { strokeWidth: 4, stroke: '#0ea5e9' },
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const { getNodes, findNode, setEdges, updateNodeInternals, dimensions } = useVueFlow({
|
const { getNodes, findNode, setEdges, updateNodeInternals, dimensions, nodes } = useVueFlow({
|
||||||
nodes: [
|
nodes: [
|
||||||
{ id: 'intro', type: 'box', position: { x: 0, y: 0 } },
|
{ id: 'intro', type: 'box', position: { x: 0, y: 0 } },
|
||||||
{ id: 'examples', type: 'box', position: { x: -50, y: 400 } },
|
{ id: 'examples', type: 'box', position: { x: -50, y: 400 } },
|
||||||
@@ -75,7 +76,8 @@ const { getNodes, findNode, setEdges, updateNodeInternals, dimensions } = useVue
|
|||||||
|
|
||||||
const el = templateRef<HTMLDivElement>('el', null)
|
const el = templateRef<HTMLDivElement>('el', null)
|
||||||
|
|
||||||
const setElements = useDebounceFn(() => {
|
const setElements = useDebounceFn(
|
||||||
|
() => {
|
||||||
const offsetX = dimensions.value.width / 2
|
const offsetX = dimensions.value.width / 2
|
||||||
const offsetY = dimensions.value.height / 4
|
const offsetY = dimensions.value.height / 4
|
||||||
|
|
||||||
@@ -175,11 +177,13 @@ const setElements = useDebounceFn(() => {
|
|||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
updateNodeInternals()
|
updateNodeInternals()
|
||||||
})
|
})
|
||||||
}, 50)
|
},
|
||||||
|
() => (currentBreakpoint.value === null ? 5 : 50),
|
||||||
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
const { stop } = useResizeObserver(el, setElements)
|
||||||
watch(dimensions, setElements, { deep: true, immediate: true })
|
|
||||||
})
|
onBeforeUnmount(stop)
|
||||||
|
|
||||||
function scrollTo() {
|
function scrollTo() {
|
||||||
const el = document.getElementById('acknowledgement')
|
const el = document.getElementById('acknowledgement')
|
||||||
|
|||||||
Reference in New Issue
Block a user