I'm using Nuxt3 with composition API
On the pages i've got swipers and videos with plyr plugin. When i open the site - everything works just great, when i move to other pages it works same way. But when i set pageTransition in nuxt config - swiper and plyr initializing only when i open the site.
I console.logged swiper instance in onMounted hook after nextTick and swiper initialization. It logged the instance but didn't init it. But when i moved from the page where it couldn't init to another one - initialization happened and the page changed.
How to init my plugins after page is ready for it? I remind - without transition in mounted hook it works fine.
That's what I do in script setup
const initSlider = async () => {
await nextTick()
setTimeout(()=> {
slider.value = new Swiper(`#${id.value}`, {
slidesPerView: 1,
slidesPerGroup: 1,
effect: 'fade',
fadeEffect: {
crossFade: true
},
modules: [EffectFade],
})
}, 400)
}
onMounted( () => {
initSlider()
})
That's my nuxt.config
export default defineNuxtConfig({
app: {
pageTransition: { name: 'page', mode: 'out-in' }
}
}
This is the css for transition
.page-enter-active,
.page-leave-active {
transition: opacity 5s;
}
.page-enter,
.page-leave-active {
opacity: 0;
}
UPD: i changed the transition mode in nuxt.config from 'out-in' to 'in-out'- now it works. But why...