Commit 55e84ae4 authored by rockyl's avatar rockyl

增加onLoopComplete和onComplete回调

parent a158773f
......@@ -53,6 +53,14 @@ export interface TweenOptions {
* 支持对象展开的字段名列表
*/
fields?: string[];
/**
* 一次循环完成回调
*/
onLoopComplete?: Function;
/**
* 完成回调
*/
onComplete?: Function;
}
/**
......@@ -122,6 +130,8 @@ export class Tween extends HashObject {
protected toProps: any;
protected ease: Function;
protected duration: number;
protected onLoopComplete: Function;
protected onComplete: Function;
constructor(host: any, target: any, options?: TweenOptions, plugins = []) {
super();
......@@ -131,6 +141,8 @@ export class Tween extends HashObject {
this.loop = options ? options.loop : 0;
this.autoPlay = options ? (options.hasOwnProperty('autoPlay') ? options.autoPlay : true) : true;
this.fields = options ? options.fields : null;
this.onLoopComplete = options.onLoopComplete;
this.onComplete = options.onComplete;
this.plugins = plugins;
......@@ -388,13 +400,19 @@ export class Tween extends HashObject {
break;
}
} else {
if (this.loop < 0) {
this._doStart();
} else if (this.loopCounting < this.loop) {
this._doStart();
} else {
this.status = STATUS.IDLE;
}
this._onEnd();
}
};
protected _onEnd(){
this.onLoopComplete && this.onLoopComplete();
if (this.loop < 0) {
this._doStart();
} else if (this.loopCounting < this.loop) {
this._doStart();
} else {
this.status = STATUS.IDLE;
this.onComplete && this.onComplete();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment