remove scroll behavior

This commit is contained in:
Kseninia Mikhaylova 2024-07-04 16:02:11 +03:00
parent 6bfbc01fce
commit 3b2e92e2b5
2 changed files with 8 additions and 9 deletions

View File

@ -3,14 +3,6 @@ const config = useRuntimeConfig()
const apiBase = config.public.apiBase const apiBase = config.public.apiBase
const { data: pagesData } = await useFetch<ApiPagesType[]>(`${apiBase}/pages/?ordering=order`) const { data: pagesData } = await useFetch<ApiPagesType[]>(`${apiBase}/pages/?ordering=order`)
const { scrollToAnchor, scrollToTop } = useAnchorScroll({
toTop: {
scrollOptions: {
behavior: 'smooth',
offsetTop: 0,
}
},
})
const route = useRoute() const route = useRoute()
</script> </script>
<template> <template>
@ -24,7 +16,7 @@ const route = useRoute()
<div class="menu"> <div class="menu">
<template v-for="item in pagesData"> <template v-for="item in pagesData">
<NuxtLink :to="item.external_link || ((route.name == 'index' ? '' : '/') + `#${item.slug}`)" <NuxtLink :to="item.external_link || ((route.name == 'index' ? '' : '/') + `#${item.slug}`)"
:target="item.external_link ? '_blank' : '_self'" @click.native="scrollToAnchor(item.slug)" event=""> :target="item.external_link ? '_blank' : '_self'">
{{ item.menu_title }} {{ item.menu_title }}
</NuxtLink> </NuxtLink>
</template> </template>

7
plugins/scroll.ts Normal file
View File

@ -0,0 +1,7 @@
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.$router.options.scrollBehavior = (to, from, savedPosition) => {
if (to.hash) {
return { el: to.hash,behavior: 'smooth', }
}
}
})