-
Notifications
You must be signed in to change notification settings - Fork 33
/
App.vue
46 lines (46 loc) · 1.79 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<template>
<div id="app">
<transition :name="transitionName">
<router-view></router-view>
</transition>
</div>
</template>
<script>
export default {
data() {
return {
// This determines if we should slide to the left or the right, depending on the route
transitionName: "slide-left"
}
},
// These two functions change the transition name between left and right
// Depending on which route it's coming from and which route it's going to
beforeRouteUpdate (to, from, next) {
const toPath = to.path;
const fromPath = from.path;
if (fromPath === '/swiping' && toPath === '/myprofile')
this.transitionName = 'slide-right';
else if (fromPath === '/myprofile' && toPath === '/settings')
this.transitionName = 'slide-right';
else if (fromPath === '/matches' && toPath === '/swiping')
this.transitionName = 'slide-right';
else
this.transitionName = 'slide-left';
setTimeout(function() { next()}, 1000);
},
watch: {
'$route' (to, from) {
const toPath = to.path;
const fromPath = from.path;
if (fromPath === '/swiping' && toPath === '/myprofile')
this.transitionName = 'slide-right';
else if (fromPath === '/myprofile' && toPath === '/settings')
this.transitionName = 'slide-right';
else if (fromPath === '/matches' && toPath === '/swiping')
this.transitionName = 'slide-right';
else
this.transitionName = 'slide-left';
}
}
};
</script>