Skip to content

Commit c3f7082

Browse files
committed
add easing functions
1 parent 9fe3c33 commit c3f7082

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

internal/animate/ease.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {InterpolationFunc} from "./types";
2+
3+
export const linear: InterpolationFunc = (progress: number) => {
4+
return progress;
5+
}
6+
7+
export const ease: InterpolationFunc = (progress: number) => {
8+
return 0.5 + 0.5 * Math.sin(Math.PI * (progress + 1.5));
9+
};
10+
11+
export const easeStart: InterpolationFunc = (progress: number) => {
12+
return progress ** 2;
13+
};
14+
15+
export const easeEnd: InterpolationFunc = (progress: number) => {
16+
return 1 - (progress - 1) ** 2;
17+
};

internal/animate/interpolate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {Shape} from "../types";
22
import {split, splitLine, mod} from "../util";
33

44
// TODO percentage > 1
5-
// TODO interpolation function (ex. easing)
65

76
const interpolateAngle = (percentage: number, a: number, b: number): number => {
87
const tau = Math.PI * 2;

internal/animate/types.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
import {Shape} from "../types";
2-
3-
export interface EasingFunc {
1+
export interface InterpolationFunc {
42
(progress: number): number;
53
}
6-
7-
export interface Keyframe {
8-
shape: Shape;
9-
easeIn: EasingFunc;
10-
easeOut: EasingFunc;
11-
}

0 commit comments

Comments
 (0)