vue-smooth-scroll on nuxt3?
how do i use vue3-smooth-scroll in nuxt3?
nuxt.config.ts
plugins: ['~/plugins/smooth-scroll.js'],
smooth-scroll.js
i set it up like this but even so, i still cant use it in my components6 Replies
I made a stackblitz playground and it works. Check it maybe you missed something?
https://stackblitz.com/edit/nuxt-starter-qeq8it?file=app.vue
Muhammad Mahmoud
StackBlitz
Nuxt - Starter (forked) - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
weird, is there any other way to control the speed of the smooth scroll?
I haven't used the plugin before. Chefk the docs I think there would be an option
docs are pretty empty, i tried using the duration property but it doesnt affect teh scroll
Sorry I don't know 😅 maybe someone can help
Global:
const app = createApp(...)
app.use(VueSmoothScroll, {
duration: 400,
updateHistory: false
})
Directive:
<div id="container">
<a href="#div-id" v-smooth-scroll="{ duration: 1000, offset: -50, container: '#container' }">Anchor</a>
<div id="div-id"></div>
</div>
Programmatic:
this.$smoothScroll({
scrollTo: this.$refs.myEl,
duration: 1000,
offset: -50,
})
Programmatic (in Vue3 setup):
const smoothScroll = Vue.inject('smoothScroll')
smoothScroll({
scrollTo: refs.myEl,
duration: 1000,
offset: -50,
})