Skip to content

Commit 33d5429

Browse files
committed
add animations example
1 parent 23d4ecd commit 33d5429

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

examples/animations/app.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import Vue from 'vue/dist/vue'
2+
import VueRouter from 'vue-router'
3+
4+
Vue.use(VueRouter)
5+
6+
const Home = {
7+
template: `
8+
<div>
9+
<h2>Home</h2>
10+
<p>hello</p>
11+
</div>
12+
`
13+
}
14+
15+
const Parent = {
16+
template: `
17+
<div class="parent">
18+
<h2>Parent</h2>
19+
<transition name="slide">
20+
<router-view class="child"></router-view>
21+
</transition>
22+
</div>
23+
`
24+
}
25+
26+
const Default = { template: '<div>default</div>' }
27+
const Foo = { template: '<div>foo</div>' }
28+
const Bar = { template: '<div>bar</div>' }
29+
30+
const router = new VueRouter({
31+
mode: 'history',
32+
base: __dirname,
33+
routes: [
34+
{ path: '/', component: Home },
35+
{ path: '/parent', component: Parent, children: [
36+
{ path: '', component: Default },
37+
{ path: 'foo', component: Foo },
38+
{ path: 'bar', component: Bar }
39+
]}
40+
]
41+
})
42+
43+
const app = new Vue({
44+
router,
45+
template: `
46+
<div id="app">
47+
<h1>Animations</h1>
48+
<ul>
49+
<li><router-link to="/">/</router-link></li>
50+
<li><router-link to="/parent">/parent</router-link></li>
51+
<li><router-link to="/parent/foo">/parent/foo</router-link></li>
52+
<li><router-link to="/parent/bar">/parent/bar</router-link></li>
53+
</ul>
54+
<transition name="fade" mode="out-in">
55+
<router-view></router-view>
56+
</transition>
57+
</div>
58+
`
59+
}).$mount('#app')

examples/animations/index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<style>
3+
.fade-enter-active, .fade-leave-active {
4+
transition: opacity .5s ease;
5+
}
6+
.fade-enter, .fade-leave-active {
7+
opacity: 0
8+
}
9+
.slide-enter-active, .slide-leave-active {
10+
position: absolute;
11+
transition: opacity .35s cubic-bezier(.55,0,.1,1),
12+
transform .35s cubic-bezier(.55,0,.1,1);
13+
}
14+
.slide-enter {
15+
opacity: 0;
16+
transform: translate(30px, 0);
17+
}
18+
.slide-leave-active {
19+
opacity: 0;
20+
transform: translate(-30px, 0);
21+
}
22+
</style>
23+
<a href="/">Examples index</a>
24+
<div id="app"></div>
25+
<script src="/__build__/shared.js"></script>
26+
<script src="/__build__/animations.js"></script>

0 commit comments

Comments
 (0)