Skip to content

Commit

Permalink
feat: export easing class
Browse files Browse the repository at this point in the history
  • Loading branch information
neuqzxy committed Dec 6, 2024
1 parent 4895fb4 commit cffc627
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 43 deletions.
3 changes: 3 additions & 0 deletions packages/vrender-core/src/animate/easing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,7 @@ export class Easing {
? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2
: (Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5)) / 2 + 1;
};
static registerFunc(name: string, func: (t: number) => number) {
(Easing as any)[name] = func;
}
}
1 change: 1 addition & 0 deletions packages/vrender-core/src/animate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './custom-animate';
export * from './morphing';
export * from './timeline';
export * from './group-fade';
export * from './easing';
86 changes: 43 additions & 43 deletions packages/vrender-core/src/interface/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,49 @@ import type { IGraphic } from './graphic';

// export type EasingType = (...args: any) => any;

export declare class Easing {
static linear(t: number): number;
static none(): typeof Easing.linear;
/**
* 获取缓动函数,amount指示这个缓动函数的插值方式
* @param amount
* @returns
*/
static get(amount: number): (t: number) => number;
static getPowIn(pow: number): (t: number) => number;
static getPowOut(pow: number): (t: number) => number;
static getPowInOut(pow: number): (t: number) => number;
static quadIn: (t: number) => number;
static quadOut: (t: number) => number;
static quadInOut: (t: number) => number;
static cubicIn: (t: number) => number;
static cubicOut: (t: number) => number;
static cubicInOut: (t: number) => number;
static quartIn: (t: number) => number;
static quartOut: (t: number) => number;
static quartInOut: (t: number) => number;
static quintIn: (t: number) => number;
static quintOut: (t: number) => number;
static quintInOut: (t: number) => number;
static getBackIn(amount: number): (t: number) => number;
static getBackOut(amount: number): (t: number) => number;
static getBackInOut(amount: number): (t: number) => number;
static backIn: (t: number) => number;
static backOut: (t: number) => number;
static backInOut: (t: number) => number;
static circIn(t: number): number;
static circOut(t: number): number;
static circInOut(t: number): number;
static bounceOut(t: number): number;
static bounceIn(t: number): number;
static bounceInOut(t: number): number;
static getElasticIn(amplitude: number, period: number): (t: number) => number;
static getElasticOut(amplitude: number, period: number): (t: number) => number;
static getElasticInOut(amplitude: number, period: number): (t: number) => number;
static elasticIn: (t: number) => number;
static elasticOut: (t: number) => number;
static elasticInOut: (t: number) => number;
}
// export declare class Easing {
// static linear(t: number): number;
// static none(): typeof Easing.linear;
// /**
// * 获取缓动函数,amount指示这个缓动函数的插值方式
// * @param amount
// * @returns
// */
// static get(amount: number): (t: number) => number;
// static getPowIn(pow: number): (t: number) => number;
// static getPowOut(pow: number): (t: number) => number;
// static getPowInOut(pow: number): (t: number) => number;
// static quadIn: (t: number) => number;
// static quadOut: (t: number) => number;
// static quadInOut: (t: number) => number;
// static cubicIn: (t: number) => number;
// static cubicOut: (t: number) => number;
// static cubicInOut: (t: number) => number;
// static quartIn: (t: number) => number;
// static quartOut: (t: number) => number;
// static quartInOut: (t: number) => number;
// static quintIn: (t: number) => number;
// static quintOut: (t: number) => number;
// static quintInOut: (t: number) => number;
// static getBackIn(amount: number): (t: number) => number;
// static getBackOut(amount: number): (t: number) => number;
// static getBackInOut(amount: number): (t: number) => number;
// static backIn: (t: number) => number;
// static backOut: (t: number) => number;
// static backInOut: (t: number) => number;
// static circIn(t: number): number;
// static circOut(t: number): number;
// static circInOut(t: number): number;
// static bounceOut(t: number): number;
// static bounceIn(t: number): number;
// static bounceInOut(t: number): number;
// static getElasticIn(amplitude: number, period: number): (t: number) => number;
// static getElasticOut(amplitude: number, period: number): (t: number) => number;
// static getElasticInOut(amplitude: number, period: number): (t: number) => number;
// static elasticIn: (t: number) => number;
// static elasticOut: (t: number) => number;
// static elasticInOut: (t: number) => number;
// }

// timeline管理一堆的animate,多个timeline互不影响
// timeline主要作用是基于layer层面的整体管理
Expand Down

0 comments on commit cffc627

Please sign in to comment.