.updateTo( vars:object, resetDuration:Boolean ) : *
{x:500}
无效,需要写成{css: {x:500}}
。
//一个通用的JavaScript对象(不是DOM元素)
var obj = {x:0, y:0, age:18, weight:180}
var tween = new TweenMax(obj, 2, {wide:100, high:200, age:40, weight:250});
//更新动画属性,并重新设定动画时长
tween.updateTo({wide:300, high:0}, true);
//更新动画属性,并使用剩余动画时长
tween.updateTo({wide:300, high:0}, false);
返回self。 参数 | 类型 | 必填 | 说明 |
---|---|---|---|
vars | object | 是 | 需要更新的属性值。只需设置要更新的属性即可,不必输入全部属性 |
resetDuration | Boolean | 否 | (default = false) 更新后是否重新计算动画时长。如果动画已经开始并resetDuration是true,动画将重新计时 |
updateTo()改变CSSPlugin插件的例子
.box {
width:50px;
height:50px;
border-radius:6px;
margin-top:4px;
}
.green{
background-color:#6fb936;
}
input{
margin-top:30px;
display:block;
}
var myTween = TweenMax.to(".box", 3, {x:500, y:100 ,opacity:0.2, rotation:360})
resetBtn = document.getElementById("resetBtn");
resetBtn.onclick = function() {
// 改变属性后动画时长重新计算3秒
myTween.updateTo({css: {x:300, y:0, opacity:0.2, rotation:360}}, true);
}
转载原创文章请注明:文章转载自:TweenMax中文网 [https://www.tweenmax.com.cn]
本文地址:https://www.tweenmax.com.cn/api/tweenmax/updateTo()