当前位置: 首页 > 文档资料 > TweenMax 中文文档 >

ease

优质
小牛编辑
120浏览
2023-12-01

ease: Ease (or Function or String)
过渡效果的速度曲线(缓动效果)。你可以在动画的参数中设置各种缓动来控制动画的变化率,赋予其特定的“感觉”。例如Elastic.easeOut或 Strong.easeInOut。默认是Power1.easeOut。

new TweenMax('.box', 3, {
    x: 500,
    ease: Bounce.easeOut
});

TweenLite中包含了基本缓动:Power0、Power1、Power2、Power3、Power4、Linear、Quad、Cubic、Quart、Quint、Strong,他们每个都含有.easeIn、.easeOut、.easeInOut参数(对于线性动画,请使用Power0.easeNone)。
而TweenMax在此基础上还另外增加了特殊缓动:Elastic、Back、Bounce、SlowMo、SteppedEase、RoughEase、Circ、Expo、Sine。
如果想在TweenLite中使用特殊缓动则需要加载缓动类easing/EasePack.min.js 。

ease适用于TweenMaxTweenLite

ease的参数

ease 示例

body {
    background: #f8f8f8;
    font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #000;
    margin: 0 10px;
    padding: 0;
}
.box {
    width:50px;
    height:50px;
    border-radius:6px;
    margin-top:4px;
    display:inline-block
  }
.green{
    background-color:#6fb936;
  }
new TweenMax('.box', 3, {
    x: 500,
    ease: Bounce.easeOut
});

ease返回值

ease的补充说明

此外,缓动效果还可以像Jquery那样写,easeOutStrong 等同于Strong.easeOut 。

在TweenMax2.0中,Power0取代了Linear,Power1取代了Quad,Power2取代了Cubic,Power3取代了Quart,Power4取代了Quint/Strong。

Back还可设定强度,如ease: Back.easeOut.config(1.7)
Elastic还可设定强度,如ease: Elastic.easeOut.config(1, 0.3)
SlowMo还可设定强度,如ease: SlowMo.ease.config(0.7, 0.7, false)
SteppedEase还可设定阶数,如ease: SteppedEase.config(12)
RoughEase还需要设定其他参数