I am looking for a solution to add and remove classes on components/elements outside of the <nuxt/>
element in layouts/default.vue
during page transitions in a Nuxt project.
As an example, I would like to animate a div
in and then out before every page transition. Pseudo code below:
<!-- layouts/default.vue -->
<template>
<site-curtain :class="{ 'is-active': isTransitioning == true }" /> // I would to apply this class during a page transition
<nuxt />
</template>
Is there an obvious way in Nuxt to listen to the page transitions that I am missing? I have looked at vue-router's beforeRouteUpdate
navigation guard but not sure if it's suitable?
Any help will be greatly appreciated!