Skip to content

Commit a9327ee

Browse files
committed
rename transition example
1 parent 33d5429 commit a9327ee

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

examples/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ <h1>Vue Router Examples</h1>
1414
<li><a href="active-links">Active Links</a></li>
1515
<li><a href="redirect">Redirect</a></li>
1616
<li><a href="route-alias">Route Alias</a></li>
17-
<li><a href="animations">Animations</a></li>
1817
<li><a href="data-fetching">Data Fetching</a></li>
18+
<li><a href="transitions">Transitions</a></li>
1919
<li><a href="navigation-guards">Navigation Guards</a></li>
2020
<li><a href="scroll-behavior">Scroll Behavior</a></li>
2121
<li><a href="auth-flow">Auth Flow</a></li>

examples/animations/app.js renamed to examples/transitions/app.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,24 @@ const Home = {
1313
}
1414

1515
const Parent = {
16+
data () {
17+
return {
18+
transitionName: 'slide-left'
19+
}
20+
},
21+
// dynamically set transition based on route change
22+
watch: {
23+
'$route' (to, from) {
24+
const toDepth = to.path.split('/').length
25+
const fromDepth = from.path.split('/').length
26+
this.transitionName = toDepth < fromDepth ? 'slide-right' : 'slide-left'
27+
}
28+
},
1629
template: `
1730
<div class="parent">
1831
<h2>Parent</h2>
19-
<transition name="slide">
20-
<router-view class="child"></router-view>
32+
<transition :name="transitionName">
33+
<router-view class="slide"></router-view>
2134
</transition>
2235
</div>
2336
`
@@ -44,7 +57,7 @@ const app = new Vue({
4457
router,
4558
template: `
4659
<div id="app">
47-
<h1>Animations</h1>
60+
<h1>Transitions</h1>
4861
<ul>
4962
<li><router-link to="/">/</router-link></li>
5063
<li><router-link to="/parent">/parent</router-link></li>

examples/animations/index.html renamed to examples/transitions/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
.fade-enter, .fade-leave-active {
77
opacity: 0
88
}
9-
.slide-enter-active, .slide-leave-active {
9+
.slide {
1010
position: absolute;
1111
transition: opacity .35s cubic-bezier(.55,0,.1,1),
1212
transform .35s cubic-bezier(.55,0,.1,1);
1313
}
14-
.slide-enter {
14+
.slide-left-enter, .slide-right-leave-active {
1515
opacity: 0;
1616
transform: translate(30px, 0);
1717
}
18-
.slide-leave-active {
18+
.slide-left-leave-active, .slide-right-enter {
1919
opacity: 0;
2020
transform: translate(-30px, 0);
2121
}
2222
</style>
2323
<a href="/">Examples index</a>
2424
<div id="app"></div>
2525
<script src="/__build__/shared.js"></script>
26-
<script src="/__build__/animations.js"></script>
26+
<script src="/__build__/transitions.js"></script>

0 commit comments

Comments
 (0)