想写一个加载动画,大概5个元素,依次执行动画。请问配置里的animation一定要是对象吗,可以是数组吗?
执行了一下,动画无规律执行,每次刷新都不一样
类似下面的形式
Page({ data: { animation: []
},
aniFun: function () {
var that = this;
var animatData = [];
//m元素的动画
var aniM = wx.createAnimation({
duration: 200,
timingFunction: 'ease-in',
delay: 0
});
aniM.translateY(-20).step();
aniM.translateY(0).step();
var ani_M = aniM.export();
//o元素的动画
var aniO = wx.createAnimation({
duration: 200,
timingFunction: 'linear',
delay: 50
});
aniO.translateY(-20).step();
aniO.translateY(0).step();
var ani_O = aniO.export();
//c元素的动画
var aniC = wx.createAnimation({
duration: 200,
timingFunction: 'linear',
delay: 100
});
aniC.translateY(-20).step();
aniC.translateY(0).step();
var ani_C = aniC.export();
//cc元素的动画
var aniCc = wx.createAnimation({
duration: 200,
timingFunction: 'linear',
delay: 150
});
aniCc.translateY(-20).step();
aniCc.translateY(0).step();
var ani_Cc = aniCc.export();
//a元素的动画
var aniA = wx.createAnimation({
duration: 200,
timingFunction: 'linear',
delay: 200
});
aniA.translateY(-20).step();
aniA.translateY(0).step();
var ani_A = aniA.export();
//传入数组animatData
animatData.push(ani_M,ani_O,ani_C,ani_Cc,ani_A);
//更新animation
that.setData({
animation: animatData;
})
console.log(that.data.animation);
// var wordAnFun = setInterval(function(){
// console.log(that.data.animation);
// that.setData({
// animation:animatData
// })
// },500)
// console.log(animatData);
}
})