@ -1,7 +1,7 @@
# 缓动函数
# 自然运动
- category: 动画
- order: 1
- order: 0
---
@ -20,9 +20,11 @@
动画停止与启动都不是瞬间完成的,因它需要一段缓冲的时间来加速或减速,因此,当动画有突然启动,停止或改变方向,都会显得很不自然。
> 以下图形,红色线与圆环为不推荐示例,蓝色为推荐示例。
#### 自然缓动
不要用直线缓动Linear做物体出入动画的缓动;注:Linear函数可做循环动画函数。
不要用直线缓动 Linear 做物体位移或 出入动画的缓动;注:Linear 函数可做循环动画函数。
如下图所示,在没有缓动的情况下启动与停止都显得突兀,感觉动画还没结束就停止了,所以在物体运动中避免直线运动。
@ -32,17 +34,17 @@
< script >
$(function (){
new Motion("#J-Linear",{lineData:[{open:[],end:[], stroke:"#f2666c"},{open:[0.455,0.03,0.515,0.955],end:[0.455,0.03,0.515,0.955], stroke:"#71B5DE",openEaseName:"easeInOutQuad",endEaseName:"easeInOutQuad"},],mask:false});
new Motion("#J-Linear",{lineData:[{stroke:"#f2666c"},{stroke:"#71B5DE",openEaseName:"easeInOutQuad",endEaseName:"easeInOutQuad"},],mask:false});
})
< / script >
上图所示缓动函数:红 `Linear` ,蓝 `easeInOutQuad ` 。
上图所示缓动函数:红 `Linear` ,蓝 `ease-in-out ` 。
#### 出入动画
不要做单向动画,进场后不做出场,直接消失元素或回到原点,会让整个画面不协调,反相只出不进也一样 。
不要做单向动画,进场后不做出场,直接消失元素或回到原点,会造成整体效果不协调和用户视觉上的闪现或其它不好的效果 。
所以有动画的进场必须要有动画的出场,包括导航上的动画。
@ -51,13 +53,13 @@ new Motion("#J-Linear",{lineData:[{open:[],end:[],stroke:"#f2666c"},{open:[0.455
< script >
$(function (){
new Motion("#J-Symmetric",{lineData:[
{open:[0.455,0.03,0.515,0.955],end:[],open EaseName:"easeInOutQuad",endEaseName:"null",stroke:"#f2666c"},
{open:[0.645,0.045,0.355,1],end:[0.645,0.045,0.355,1], stroke:"#71B5DE",openEaseName:"easeInOutCubic",endEaseName:"easeInOutCubic"}],
{openEaseName:"easeInOutQuad",endEaseName:"null",stroke:"#f2666c"},
{stroke:"#71B5DE",openEaseName:"easeInOutCubic",endEaseName:"easeInOutCubic"}],
mask:false,exposure:"top"});
})
< / script >
上图所示缓动函数:红 `easeInOutQuad` ,蓝 `easeInOutC ubic` 。
上图所示缓动函数:红 `ease-in-out` ,蓝 `ease-in-out-c ubic` 。
##### 场外出入
@ -72,14 +74,14 @@ mask:false,exposure:"top"});
< script >
$(function (){
new Motion("#J-Entry", {lineData:[
{open:[0.25,0.46,0.45,0.94],end:[0.25,0.46,0.45,0.94],openEaseName:"easeOutQuad",endEaseName:"easeOutQuad",stroke:"#f2666c"},
{open:[0.215,0.61,0.355,1],end:[0.55,0.055,0.675,0.19],stroke:"#71B5DE",openEaseName:"easeOutCubic",endEaseName:"easeInCubic"}],
mask:true, exposure:"bottom"});
new Motion("#J-Entry", {lineData:[
{openEaseName:"easeOutQuad",endEaseName:"easeOutQuad",stroke:"#f2666c"},
{stroke:"#71B5DE",openEaseName:"easeOutCubic",endEaseName:"easeInCubic"}],
mask:true, exposure:"bottom"});
})
< / script >
上图所示缓动函数:红 `easeOutQuad` `easeOutQuad` ,蓝 `easeOutCubic` `easeInC ubic` 。
上图所示缓动函数:红 `ease-out` `ease-out` ,蓝 `ease-out-cubic` `ease-in-c ubic` 。
示例组件:[Message 全局提示](/components/message/),[Dropdown 下拉菜单](/components/dropdown/)。
@ -91,35 +93,36 @@ mask:true,exposure:"bottom"});
2. 如球类物体掉地上的后,反弹几次后停止。
- 曲线图用的是3次贝塞尔曲线,没法表示Bounce,所以用line替换。
- 弹性动画最好结合alpha。
- 弹性动画最好结合 alpha。
> 慎用Bounce或Elastic,这两种适用在特殊元素下,一般back即可满足页面上元素的弹动;
< div id = "J-Back" > < / div >
< script >
$(function (){
new Motion("#J-Back",{lineData:[
{open:[,end:[0.455,0.03,0.515,0.955],open EaseName:"easeOutBounce",endEaseName:"easeInOutQuad ",stroke:"#70f266"},
{open:[0.175,0.885,0.32,1.275],end:[0.6,-0.28,0.735,0.045], stroke:"#71B5DE",openEaseName:"easeOutBack",endEaseName:"easeInBack"}],
{openEaseName:"easeOutBounce",endEaseName:"easeOutElastic ",stroke:"#70f266"},
{stroke:"#71B5DE",openEaseName:"easeOutBack",endEaseName:"easeInOut Back"}],
mask:false,exposure:"top"});
})
< / script >
上图所示缓动函数:红 `easeOutBounce` `easeInOutQuad` ,蓝 `easeOutBack` `easeInB ack` 。
上图所示缓动函数:绿 `easeOutBounce` `easeOutElastic` ( css 需自配), 蓝 `ease-out-back` `ease-in-b ack` 。
## 缓动函数
Ant Design 提供了一套缓动函数规范动画行为。
Ant Design 提供了一套缓动函数规范动画行为供组件使用 。
|名称 |参数 |说明与适用 |
|名称 |参数 |说明 |
|-------------------|------------------------------------------|---------------------------|
|@ease-out | `cubic-bezier(0.215,0.61,0.355,1);` |默认后缓动;适合元素展开时; |
|@ease-in | `cubic-bezier(0.55,0.055,0.675,0.19);` |默认前缓动;适合元素关闭时; |
|@ease-in-out | `cubic-bezier(0.645,0.045,0.355,1);` |默认前后缓动;适合元素移动; |
|@ease-out-back | `cubic-bezier(0.18,0.89,0.32,1.28);` |结束回动;适合弹出框出现时; |
|@ease-in-back | `cubic-bezier(0.6,-0.3,0.74,0.05);` |开始回动;适合弹出框关闭; |
|@ease-out | `cubic-bezier(0.215,0.61,0.355,1);` |默认后缓动; |
|@ease-in | `cubic-bezier(0.55,0.055,0.675,0.19);` |默认前缓动; |
|@ease-in-out | `cubic-bezier(0.645,0.045,0.355,1);` |默认前后缓动; |
|@ease-out-back | `cubic-bezier(0.18,0.89,0.32,1.28);` |结束回动; |
|@ease-in-back | `cubic-bezier(0.6,-0.3,0.74,0.05);` |开始回动; |
|@ease-in-out-back | `cubic-bezier(0.68,-0.55,0.27,1.55);` |前后回动; |
|@ease-out-circ | `cubic-bezier(0.08,0.82,0.17,1);` |圆形后缓动;适合元素展开时; |
|@ease-in-circ | `cubic-bezier(0.6,0.04,0.98,0.34);` |圆形前缓动;适合元素关闭时; |
|@ease-in-out-circ | `cubic-bezier(0.78,0.14,0.15,0.86);` |圆形缓动;适合元素移动; |
|@ease-out-circ | `cubic-bezier(0.08,0.82,0.17,1);` |圆形后缓动; |
|@ease-in-circ | `cubic-bezier(0.6,0.04,0.98,0.34);` |圆形前缓动; |
|@ease-in-out-circ | `cubic-bezier(0.78,0.14,0.15,0.86);` |圆形前后缓动; |