Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tween custom easing property #8321

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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