Skip to content

Commit 791a756

Browse files
committed
update: transitioning-state
1 parent d00dfb5 commit 791a756

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/guide/transitioning-state.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ type: guide
44
order: 13
55
---
66

7-
Vue's transition system offers many simple ways to animate entering, leaving, and lists, but what about animating your data itself? For example:
7+
Vue 的过渡系统提供了非常多简单的方法设置进入、离开和列表的动效。那么对于数据元素本身的动效呢,比如:
88

9-
- numbers and calculations
10-
- colors displayed
11-
- the positions of SVG nodes
12-
- the sizes and other properties of elements
9+
- 数字和运算
10+
- 颜色的显示
11+
- SVG 节点的位置
12+
- 元素的大小和其他的属性
1313

14-
All of these are either already stored as raw numbers or can be converted into numbers. Once we do that, we can animate these state changes using 3rd-party libraries to tween state, in combination with Vue's reactivity and component systems.
14+
所有的原始数字都被事先存储起来,可以直接转换到数字。做到这一步,我们就可以结合 Vue 的响应式和组件系统,使用第三方库来实现切换元素的过渡状态。
1515

16-
## Animating State with Watchers
1716

18-
Watchers allow us to animate changes of any numerical property into another property. That may sound complicated in the abstract, so let's dive into an example using Tween.js:
17+
## 状态动画 与 watcher
18+
19+
通过 watcher 我们能监听到任何数值属性的数值更新。可能听起来很抽象,所以让我们先来看看使用Tweenjs一个例子:
1920

2021
``` html
2122
<script src="https://npmcdn.com/tween.js@16.3.4"></script>
@@ -87,7 +88,8 @@ new Vue({
8788
</script>
8889
{% endraw %}
8990

90-
When you update the number, the change is animated below the input. This makes for a nice demo, but what about something that isn't directly stored as a number, like any valid CSS color for example? Here's how we could accomplish this with the addition of Color.js:
91+
当你输入新数值时,就会触发动画。这个是一个不错的演示,但是对于不能直接像数字一样存储的值,比如 CSS 中的 color 的值,通过下面的例子我们来通过 Color.js 实现一个例子:
92+
9193

9294
``` html
9395
<script src="https://npmcdn.com/tween.js@16.3.4"></script>
@@ -239,9 +241,10 @@ new Vue({
239241
</style>
240242
{% endraw %}
241243

242-
## Dynamic State Transitions
244+
## 动态状态转换
245+
246+
就像 Vue 的过渡组件一样,数据背后状态转换会实时更新,这对于原型设计十分有用。当你修改一些变量,即使是一个简单的 SVG 多边形也可是实现很多难以想象的效果。
243247

244-
Just as with Vue's transition components, the data backing state transitions can be updated in real time, which is especially useful for prototyping! Even using a simple SVG polygon, you can achieve many effects that would be difficult to conceive of until you've played with the variables a little.
245248

246249
{% raw %}
247250
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.5/TweenLite.min.js"></script>
@@ -376,9 +379,10 @@ function generatePoints (stats) {
376379

377380
See [this fiddle](https://jsfiddle.net/chrisvfritz/fbvusejy/) for the complete code behind the above demo.
378381

379-
## Organizing Transitions into Components
382+
## 组织Organizing Transitions into Components
380383

381-
Managing many state transitions can quickly increase the complexity of a Vue instance or component. Fortunately, many animations can be extracted out into dedicated child components. Let's do this with the animated integer from our earlier example:
384+
管理太多的状态转换的很快会接近到 Vue 实例或者组件的复杂性,不过,很多动画可以提取到专用的子组件。
385+
我们来将之前的示例改写一下:
382386

383387
``` html
384388
<script src="https://npmcdn.com/tween.js@16.3.4"></script>
@@ -396,10 +400,10 @@ Managing many state transitions can quickly increase the complexity of a Vue ins
396400
```
397401

398402
``` js
399-
// This complex tweening logic can now be reused between
400-
// any integers we may wish to animate in our application.
401-
// Components also offer a clean interface for configuring
402-
// more dynamic transitions and complex transition
403+
// 这种复杂的补间动画逻辑可以被复用
404+
// 任何整数都可以执行动画
405+
// 组件化使我们的界面十分清晰
406+
// 可以支持更多更复杂的动态过渡
403407
// strategies.
404408
Vue.component('animated-integer', {
405409
template: '<span>{{ tweeningValue }}</span>',
@@ -521,4 +525,5 @@ new Vue({
521525
</script>
522526
{% endraw %}
523527

524-
Within child components, we can use any combination of transition strategies that have been covered on this page, along with those offered by Vue's [built-in transition system](transitions.html). Together, there are very few limits to what can be accomplished.
528+
我们能在组件中结合使用这一节讲到各种过渡策略和 Vue [内建的过渡系统](transitions.html)。总之,对于完成各种过渡动效几乎没有阻碍。
529+

0 commit comments

Comments
 (0)