Skip to content

Commit f45528b

Browse files
committed
update transition doc
1 parent 0913d46 commit f45528b

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

source/guide/transitions.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,37 @@ With the directive `v-transition="my-transition"` applied, Vue will:
2020
A typical CSS transition looks like this:
2121

2222
``` html
23-
<p class="msg" v-if="show" v-transition="expand">Hello!</p>
23+
<div v-if="show" v-transition="expand">Hello!</div>
2424
```
2525

26-
You also need to define CSS rules for `.expand-enter` and `.expand-leave` classes:
26+
You also need to define CSS rules for `.expand-transition`, `.expand-enter` and `.expand-leave` classes:
2727

2828
``` css
29-
.msg {
29+
.expand-transition {
3030
transition: all .3s ease;
3131
height: 30px;
3232
padding: 10px;
3333
background-color: #eee;
3434
overflow: hidden;
3535
}
36-
.msg.expand-enter, .msg.expand-leave {
36+
.expand-enter, .expand-leave {
3737
height: 0;
3838
padding: 0 10px;
3939
opacity: 0;
4040
}
4141
```
4242

43-
<div id="demo"><p class="msg" v-if="show" v-transition="expand">Hello!</p><button v-on="click: show = !show">Toggle</button></div>
43+
<div id="demo"><div v-if="show" v-transition="expand">Hello!</div><button v-on="click: show = !show">Toggle</button></div>
4444

4545
<style>
46-
.msg {
47-
transition: all .5s ease;
46+
.expand-transition {
47+
transition: all .3s ease;
4848
height: 30px;
49+
padding: 10px;
4950
background-color: #eee;
5051
overflow: hidden;
51-
padding: 10px;
52-
margin: 0 !important;
5352
}
54-
.msg.expand-enter, .msg.expand-leave {
53+
.expand-enter, .expand-leave {
5554
height: 0;
5655
padding: 0 10px;
5756
opacity: 0;
@@ -65,7 +64,7 @@ new Vue({
6564
})
6665
</script>
6766

68-
The classes being toggled are based on the value of your `v-transition` directive. In the case of `v-transition="fade"`, the classes being toggled will be `.fade-enter` and `.fade-leave`. When no value is provided they will default to `.v-enter` and `.v-leave`.
67+
The classes being added and toggled are based on the value of your `v-transition` directive. In the case of `v-transition="fade"`, the class `.fade-transition` will be always present, and the classes `.fade-enter` and `.fade-leave` will be toggled automatically at the right moments. When no value is provided they will default to `.v-transition`, `.v-enter` and `.v-leave`.
6968

7069
When the `show` property changes, Vue.js will insert or remove the `<p>` element accordingly, and apply transition classes as specified below:
7170

@@ -89,17 +88,14 @@ CSS animations are applied in the same way with CSS transitions, the difference
8988
**Example:** (omitting prefixed CSS rules here)
9089

9190
``` html
92-
<p class="animated" v-if="show" v-transition="bounce">Look at me!</p>
91+
<span v-show="show" v-transition="bounce">Look at me!</span>
9392
```
9493

9594
``` css
96-
.animated {
97-
display: inline-block;
98-
}
99-
.animated.bounce-enter {
95+
.bounce-enter {
10096
animation: bounce-in .5s;
10197
}
102-
.animated.bounce-leave {
98+
.bounce-leave {
10399
animation: bounce-out .5s;
104100
}
105101
@keyframes bounce-in {
@@ -126,17 +122,14 @@ CSS animations are applied in the same way with CSS transitions, the difference
126122
}
127123
```
128124

129-
<div id="anim" class="demo"><span class="animated" v-if="show" v-transition="bounce">Look at me!</span><br><button v-on="click: show = !show">Toggle</button></div>
125+
<div id="anim" class="demo"><span v-show="show" v-transition="bounce">Look at me!</span><br><button v-on="click: show = !show">Toggle</button></div>
130126

131127
<style>
132-
.animated {
133-
display: inline-block;
134-
}
135-
.animated.bounce-enter {
128+
.bounce-enter {
136129
-webkit-animation: bounce-in .5s;
137130
animation: bounce-in .5s;
138131
}
139-
.animated.bounce-leave {
132+
.bounce-leave {
140133
-webkit-animation: bounce-out .5s;
141134
animation: bounce-out .5s;
142135
}

0 commit comments

Comments
 (0)