Scratchpad/

Exponential easing

This simple easing function takes an arbitrary power as a second argument, allowing for exponential easing to any power

const easeInOut = (t, p = 5) =>
  t <= 0.5
    ? Math.pow(t * 2, p) / 2
    : 1 - Math.pow(2 - t * 2, p) / 2

Rather than separate declarations for cubicInOut, quartInOut and quintInOut easing functions, this method allows for easing to any power by passing a second argument p. t is assumed to be normalised between 0 and 1. Values of p below 1 result in inverse easing, where the object enters at full speed, slows down and then accelerates out.

p = 0.1p = 0.1
p = 0.2p = 0.2
p = 0.3p = 0.3
p = 0.4p = 0.4
p = 0.5p = 0.5
p = 0.6p = 0.6
p = 0.7p = 0.7
p = 0.8p = 0.8
p = 0.9p = 0.9
p = 1p = 1
p = 2p = 2
p = 3p = 3
p = 4p = 4
p = 5p = 5
p = 6p = 6
p = 7p = 7
p = 8p = 8
p = 9p = 9
p = 10p = 10