和上一个差别不大
Animation.prototype.changeSrc = function (el,imgList) {
var me = this;
var len = imgList.length;
var taskFn;
var type;
if (len) {
taskFn = function (next, time) {
var index = Math.min(time / me.interval | 0 , len-1);
el.src = imageList[index]
//结束时跳到下一个
if (index === len - 1) {
next();
}
}
type = TASK_ASYNC;
} else {
//这里的next就是全局方法 next
taskFn = next;
type = TASK_SYNC;
}
return this._add(taskFn,type)
}