Skip to content

Instantly share code, notes, and snippets.

@yukulele yukulele/easing.ts
Last active Apr 22, 2018

Embed
What would you like to do?
Simple Easing Functions in Typescript
class Ease {
static in(t: number, p = 1) {
return t ** p
}
static out(t: number, p = 1) {
return 1 - Ease.in(1 - t, p)
}
static inOut(t: number, p = 1):number {
if (t <= 0.5) {
return Ease.in(t * 2, p) / 2
}
return 1 - Ease.inOut(1 - t, p)
}
}
Ease.in(t) // linear(t)
Ease.in(t, 2) // easeInQuad(t)
Ease.out(t, 3) // easeOutCubic(t)
Ease.inOut(t, 5) // easeInOutQuint(t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.