Skip to content

Commit

Permalink
fix tween custom easing property (#8321)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayceLai committed Mar 4, 2021
1 parent e9a7bea commit 30d27a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cocos/tween/export-api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/ban-types */
/*
Copyright (c) 2020 Xiamen Yaji Software Co., Ltd.
Expand Down Expand Up @@ -35,7 +36,7 @@
* 内置缓动函数的字符串值定义。
*/
export type TweenEasing =
'linear' | 'smooth' | 'fade' |
'linear' | 'smooth' | 'fade' | 'constant' |
'quadIn' | 'quadOut' | 'quadInOut' | 'quadOutIn' |
'cubicIn' | 'cubicOut' | 'cubicInOut' | 'cubicOutIn' |
'quartIn' | 'quartOut' | 'quartInOut' | 'quartOutIn' |
Expand Down
1 change: 1 addition & 0 deletions cocos/tween/set-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class SetAction extends ActionInstant {
constructor (props?: any) {
super();
this._props = {};
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
props !== undefined && this.init(props);
}

Expand Down
10 changes: 5 additions & 5 deletions cocos/tween/tween-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,21 @@ export class TweenAction extends ActionInterval {
let value = props[name];
if (value == null || typeof value === 'string' || typeof value === 'function') continue;
// property may have custom easing or progress function
let easing: any; let progress: any;
let customEasing: any; let progress: any;
if (value.value !== undefined && (value.easing || value.progress)) {
if (typeof value.easing === 'string') {
easing = easing[value.easing];
if (!easing) warnID(1031, value.easing);
customEasing = easing[value.easing];
if (!customEasing) warnID(1031, value.easing);
} else {
easing = value.easing;
customEasing = value.easing;
}
progress = value.progress;
value = value.value;
}

const prop = Object.create(null);
prop.value = value;
prop.easing = easing;
prop.easing = customEasing;
prop.progress = progress;
this._props[name] = prop;
}
Expand Down

0 comments on commit 30d27a6

Please sign in to comment.