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

TweenLite.onOverwrite

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

TweenLite.onOverwrite : Function
当一个补间动画被另外一个补间动画覆盖时产生的事件函数。

TweenLite.onOverwrite = function(overwritten, overwriting, target, props) {...}

TweenLite.onOverwrite适用于TweenLite

TweenLite.onOverwrite的参数

onOverwrite可以传递以下参数。

参数类型说明
overwrittenTweenTween被覆盖的补间动画
overwritingTweenTween覆盖的补间动画
targetObject动画目标(只有"auto"模式才会传递此参数),与overwrittenTween.target类似
例如:TweenLite.to([obj1, obj2], 1, {x:100}) 和 TweenLite.to(obj2, 1, {x:50}), 目标应是 obj2
overwrittenPropertiesArray一个属性数组,包含了被覆盖的动画属性(只有"auto"模式才会传递此参数),
例如:["x","y","opacity"]

TweenLite.onOverwrite 示例

Box
.box {
    width:50px;
    height:50px;
    line-height:50px;
    text-align:center;
    color:#fff;
    border-radius:6px;
    margin-top:4px;
    display:inline-block
  }
.green{
    background-color:#6fb936;
  }
TweenLite.onOverwrite = function(overwritten, overwriting, target, props) {
  console.log("被覆盖的动画");
  console.log(overwritten);
  
  console.log("覆盖的动画")
  console.log(overwriting);
  
  console.log("被覆盖的动画的目标对象");
  console.log(target.innerHTML);
  
  console.log("被覆盖的属性");
  console.log(props);
}
TweenLite.to(".green", 2, {x:400, y:200});
//after 1 second the next tween will overwrite the x property of the previous tween
TweenLite.to(".green", 1, {x:100, delay:1});

TweenLite.onOverwrite返回值

TweenLite.onOverwrite的补充说明