Skip to content

Commit

Permalink
✨ add transition between routes
Browse files Browse the repository at this point in the history
Fixes Page transition effect should be implemented #13
  • Loading branch information
doroudi committed May 2, 2024
1 parent 2014045 commit cebc852
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
<n-layout :native-scrollbar="false" position="static">
<div class="main-content flex-1 bg-slate-100 dark:bg-slate-800 dark:text-white my-2 mr-2">
<Navbar />
<div class="p-3">
<RouterView />
<div class="p-3 relative">
<router-view v-slot="{ Component, route }">
<transition name="route" mode="out-in">
<div :key="route">
<component :is="Component" />
</div>
</transition>
</router-view>
</div>
</div>
</n-layout>
Expand Down
1 change: 1 addition & 0 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ html.dark {
width: 100%;
height: 2px;
}

32 changes: 32 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,35 @@ body {
@import 'utils/override';
@import 'utils/animations';


// .fade-enter-active,
// .fade-leave-active {
// transition: opacity 0.5s ease;
// }

// .fade-enter-from,
// .fade-leave-to {
// opacity: 0;
// }

// .slide-fade-enter-active {
// position: absolute;
// inset: 0;
// z-index:10;
// transition: all 0.3s ease-out;
// background: #FFF;
// }

// .slide-fade-leave-active {
// position: absolute;
// inset: 0;
// z-index: 1;
// background: #FFF;
// transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
// }

// .slide-fade-enter-from,
// .slide-fade-leave-to {
// transform: translateY(20px);
// opacity: 0;
// }
23 changes: 22 additions & 1 deletion src/styles/utils/_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,25 @@
-webkit-transform: rotateZ(0);
transform-origin: 50% 0%;
}
}
}

// router-animation

.route-enter-from {
opacity: 0;
transform: translateY(100px);
}

.route-enter-active {
transition: all 0.3s ease-out;

}

.route-leave-to {
opacity: 0;
transform: translateY(-100px);
}

.route-leave-active {
transition: all 0.3s ease-in;
}
1 change: 0 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export default defineConfig({
AutoImport({
imports: [
'vue',
'vue-router',
'vue/macros',
'vue-i18n',
'@vueuse/head',
Expand Down

0 comments on commit cebc852

Please sign in to comment.