You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/transitions.md
+38-36Lines changed: 38 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -844,9 +844,11 @@ new Vue({
844
844
</style>
845
845
{% endraw %}
846
846
847
-
With one simple attribute addition, we've fixed that original transition without having to add any special styling.
847
+
只用添加一个简单的属性,就解决了之前的过渡问题而无需任何额外的代码。
848
+
849
+
`in-out` 模式不是经常用到,但对于一些稍微不同的过渡效果还是有用的。
850
+
将之前的滑动淡出的例子结合:
848
851
849
-
The `in-out` mode isn't used as often, but can sometimes be useful for a slightly different transition effect. Let's try combining it with the slide-fade transition we worked on earlier:
Transitioning between components is even simpler - we don't even need the `key` attribute. Instead, we just wrap a [dynamic component](components.html#Dynamic-Components):
900
903
901
904
```html
902
905
<transitionname="component-fade"mode="out-in">
@@ -964,21 +967,21 @@ new Vue({
964
967
</script>
965
968
{% endraw %}
966
969
967
-
## List Transitions
970
+
## 列表过渡
968
971
969
-
So far, we've managed transitions for:
972
+
目前为止,我们已经讲到:
970
973
971
-
-Individual nodes
972
-
-Multiple nodes where only 1 is rendered at a time
974
+
-单个节点
975
+
-多个节点中渲染一个节点
973
976
974
-
So what about for when we have a whole list of items we want to render simultaneously, for example with `v-for`? In this case, we'll use the `<transition-group>`component. Before we dive into an example though, there are a few things that are important to know about this component:
Now let's dive into a simple example, transitioning entering and leaving using the same CSS classes we've used previously:
984
+
现在让我们由一个简单的例子深入,进入和离开的过渡使用之前一样的 CSS 类名。
982
985
983
986
```html
984
987
<divid="list-demo"class="demo">
@@ -1072,13 +1075,14 @@ new Vue({
1072
1075
</style>
1073
1076
{% endraw %}
1074
1077
1075
-
There's one problem with this example. When you add or remove an item, the ones around it instantly snap into their new place instead of smoothly transitioning. We'll fix that later.
The `<transition-group>`component has another trick up its sleeve. It can not only animate entering and leaving, but also changes in position. The only new concept you need to know to use this feature is the addition of **the`v-move` class**, which is added when items are changing positions. Like the other classes, its prefix will match the value of match a provided `name`attribute and you can also manually specify a class with the `move-class`attribute.
1083
+
`<transition-group>`组件还有一个特性。不仅可以进入和离开动画,还可以改变定位。要使用这个新功能只了解新增 **`v-move` class 类名**,它会在元素的改变定位的过程中应用。像之前的类名一样,可以通过 `name`属性来自定义前缀,也可以通过 `move-class`属性手动设置。
1080
1084
1081
-
This class is mostly useful for specifying the transition timing and easing curve, as you'll see below:
This might seem like magic, but under the hood, Vue is using a simple animation technique called [FLIP](https://aerotwist.com/blog/flip-your-animations/) to smoothly transition elements from their old position to their new position using transforms.
1147
-
1148
-
We can combine this technique with our previous implementation to animate every possible change to our list!
<pclass="tip">One important note is that these FLIP transitions do not work with elements set to `display: inline`. As an alternative, you can use `display: inline-block` or place elements in a flex context.</p>
These FLIP animations are also not limited to a single axis. Items in a multidimensional grid can transitioned [just as easily](https://jsfiddle.net/chrisvfritz/a2ngorat/):
Transitions can be reused through Vue's component system. To create a reusable transition, all you have to do is place a `<transition>`or`<transition-group>`component at the root, then pass any children into the transition component.
This can be useful when you've defined CSS transitions/animations using Vue's transition class conventions and simply want to switch between them.
1535
-
1536
-
Really though, any transition attribute can be dynamically bound. And it's not just attributes. Since event hooks are just methods, they have access to any data in the context. That means depending on the state of your component, your JavaScript transitions can behave differently.
Finally, the ultimate way of creating dynamic transitions is through components that accept props to change the nature of the transition(s) to be used. It may sound cheesy, but the only limit really is your imagination.
0 commit comments