Skip to content

Instantly share code, notes, and snippets.

@conradfuhrman
Created October 23, 2020 13:27
Show Gist options
  • Save conradfuhrman/addc023c340af78d3ac4a0f454238452 to your computer and use it in GitHub Desktop.
Save conradfuhrman/addc023c340af78d3ac4a0f454238452 to your computer and use it in GitHub Desktop.
Vue Page Transition, Inertia.js
<template>
<h1>About Us Component</h1>
<h3>{{ url }}</h3>
<p>Test fade/in out on page transition</p>
</template>
<script>
import Layout from './Layout'
export default {
layout: Layout,
props: {
url: {
default: '',
type: String
},
page: {
default: {},
type: Object
}
}
}
</script>
<template>
<h4>Layout Template</h4>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about-us">About Us</a></li>
</ul>
<ul>
<li><inertia-link href="/">Home</inertia-link></li>
<li><inertia-link href="/about-us">About Us</inertia-link></li>
</ul>
<transition name="page" mode="out-in">
<div v-if="animate">
<slot />
</div>
</transition>
</template>
<script>
export default {
data(){
return{
animate: false,
};
},
mounted(){
console.log('mounted layout')
this.animate = true
},
};
</script>
<template>
<h1>Page Component</h1>
<h3>{{ url }}</h3>
</template>
<script>
import Layout from './Layout'
export default {
layout: Layout,
props: {
url: {
default: '',
type: String
},
page: {
default: {},
type: Object
}
}
}
</script>
.page-enter-active,
.page-leave-active {
transition: all 5s;
}
.page-enter-from,
.page-leave-to {
opacity: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment