Easing
The Easing module implements common easing functions. You can use it with the interpolate() API.
You can find a visualization of some common easing functions at http://easings.net/
Predefined animations
The Easing module provides several predefined animations through the following methods:
backprovides a basic animation where the object goes slightly back before moving forwardbounceprovides a bouncing animationeaseprovides a basic inertial animationelasticprovides a basic spring interaction
Standard functions
Three standard easing functions are provided:
The poly function can be used to implement quartic, quintic, and other higher power functions.
Additional functions
Additional mathematical functions are provided by the following methods:
bezierprovides a cubic bezier curvecircleprovides a circular functionsinprovides a sinusoidal functionexpprovides an exponential function
The following helpers are used to modify other easing functions.
inruns an easing function forwardsinOutmakes any easing function symmetricaloutruns an easing function backwards
Example
tsximport {Easing ,interpolate } from "remotion";constMyVideo :React .FC = () => {constframe =useCurrentFrame ();constinterpolated =interpolate (frame , [0, 100], [0, 1], {easing :Easing .bezier (0.8, 0.22, 0.96, 0.65),extrapolateLeft : "clamp",extrapolateRight : "clamp",});return (<AbsoluteFill style ={{transform : `scale(${interpolated })`,backgroundColor : "red",}}/>);};
tsximport {Easing ,interpolate } from "remotion";constMyVideo :React .FC = () => {constframe =useCurrentFrame ();constinterpolated =interpolate (frame , [0, 100], [0, 1], {easing :Easing .bezier (0.8, 0.22, 0.96, 0.65),extrapolateLeft : "clamp",extrapolateRight : "clamp",});return (<AbsoluteFill style ={{transform : `scale(${interpolated })`,backgroundColor : "red",}}/>);};
Reference
Methods
step0
jsxstatic step0(n): number
jsxstatic step0(n): number
A stepping function, returns 1 for any positive value of n.
step1
jsxstatic step1(n): number
jsxstatic step1(n): number
A stepping function, returns 1 if n is greater than or equal to 1.
linear
jsxstatic linear(t): number
jsxstatic linear(t): number
A linear function, f(t) = t. Position correlates to elapsed time one to one.
http://cubic-bezier.com/#0,0,1,1
ease
jsxstatic ease(t): number
jsxstatic ease(t): number
A basic inertial interaction, similar to an object slowly accelerating to speed.
http://cubic-bezier.com/#.42,0,1,1
quad
jsxstatic quad(t): number
jsxstatic quad(t): number
A quadratic function, f(t) = t * t. Position equals the square of elapsed time.
http://easings.net/#easeInQuad
cubic
jsxstatic cubic(t): number
jsxstatic cubic(t): number
A cubic function, f(t) = t * t * t. Position equals the cube of elapsed time.
http://easings.net/#easeInCubic
poly()
jsxstatic poly(n): (t) => number
jsxstatic poly(n): (t) => number
A power function. Position is equal to the Nth power of elapsed time.
n = 4: http://easings.net/#easeInQuart n = 5: http://easings.net/#easeInQuint
sin
jsxstatic sin(t): number
jsxstatic sin(t): number
A sinusoidal function.
http://easings.net/#easeInSine
circle
jsxstatic circle(t): number
jsxstatic circle(t): number
A circular function.
http://easings.net/#easeInCirc
exp
jsxstatic exp(t): number
jsxstatic exp(t): number
An exponential function.
http://easings.net/#easeInExpo
elastic()
jsxstatic elastic(bounciness): (t) => number
jsxstatic elastic(bounciness): (t) => number
A basic elastic interaction, similar to a spring oscillating back and forth.
Default bounciness is 1, which overshoots a little bit once. 0 bounciness doesn't overshoot at all, and bounciness of N > 1 will overshoot about N times.
http://easings.net/#easeInElastic
back()
jsxstatic back(s): (t) => number
jsxstatic back(s): (t) => number
Use with Animated.parallel() to create a basic effect where the object animates back slightly as the animation starts.
bounce
jsxstatic bounce(t): number
jsxstatic bounce(t): number
Provides a basic bouncing effect.
http://easings.net/#easeInBounce
See an example of how you might use it below
jsxinterpolate(0.5, [0, 1], [0, 1], {easing: Easing.bounce,});
jsxinterpolate(0.5, [0, 1], [0, 1], {easing: Easing.bounce,});
bezier()
jsxstatic bezier(x1, y1, x2, y2) => (t): number
jsxstatic bezier(x1, y1, x2, y2) => (t): number
Provides a cubic bezier curve, equivalent to CSS Transitions' transition-timing-function.
A useful tool to visualize cubic bezier curves can be found at http://cubic-bezier.com/
jsxinterpolate(0.5, [0, 1], [0, 1], {easing: Easing.bezier(0.5, 0.01, 0.5, 1),});
jsxinterpolate(0.5, [0, 1], [0, 1], {easing: Easing.bezier(0.5, 0.01, 0.5, 1),});
in(easing)
jsxstatic in(easing: (t: number) => number): (t: number) => number;
jsxstatic in(easing: (t: number) => number): (t: number) => number;
Runs an easing function forwards.
jsx{easing: Easing.in(Easing.ease);}
jsx{easing: Easing.in(Easing.ease);}
out()
jsxstatic out(easing: (t: number) => number): (t: number) => number;
jsxstatic out(easing: (t: number) => number): (t: number) => number;
Runs an easing function backwards.
jsx{easing: Easing.out(Easing.ease);}
jsx{easing: Easing.out(Easing.ease);}
inOut()
jsxstatic inOut(easing: (t: number) => number): (t: number) => number;
jsxstatic inOut(easing: (t: number) => number): (t: number) => number;
jsx{easing: Easing.inOut(Easing.ease);}
jsx{easing: Easing.inOut(Easing.ease);}
Makes any easing function symmetrical. The easing function will run forwards for half of the duration, then backwards for the rest of the duration.
Credits
The Easing API is the exact same as the one from React Native and the documentation has been copied over. Credit goes to them for this excellent API.
