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
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.
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:
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 实现一个例子:
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.
@@ -376,9 +379,10 @@ function generatePoints (stats) {
376
379
377
380
See [this fiddle](https://jsfiddle.net/chrisvfritz/fbvusejy/) for the complete code behind the above demo.
378
381
379
-
## Organizing Transitions into Components
382
+
## 组织Organizing Transitions into Components
380
383
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:
@@ -396,10 +400,10 @@ Managing many state transitions can quickly increase the complexity of a Vue ins
396
400
```
397
401
398
402
```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
+
//可以支持更多更复杂的动态过渡
403
407
// strategies.
404
408
Vue.component('animated-integer', {
405
409
template:'<span>{{ tweeningValue }}</span>',
@@ -521,4 +525,5 @@ new Vue({
521
525
</script>
522
526
{% endraw %}
523
527
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.
0 commit comments