Skip to main content

svelte/easing

This module provides easing functions for transitions, animations, and the svelte/motion module.

An easing function receives the elapsed progress t, from 0 at the start to 1 at the end, and returns the eased progress. Svelte uses this value to interpolate between the starting and ending values. For example, cubicIn(0.5) returns 0.125, so a numeric tween from 0 to 100 with this easing reaches 12.5 halfway through its duration.

You can also supply your own easing function, such as (t) => t * t. It should return 0 for t = 0 and 1 for t = 1. The return value is an absolute progress value, not an increment from the previous call. Return the same value for the same input: when generating CSS transition keyframes, Svelte calls the function repeatedly before the transition begins.

The return value is not restricted to the range 0 to 1. For example, backIn returns negative values and elasticOut can return values greater than 1, causing the animation to move beyond its starting or ending value before settling.

import {
	backIn,
	backInOut,
	backOut,
	bounceIn,
	bounceInOut,
	bounceOut,
	circIn,
	circInOut,
	circOut,
	cubicIn,
	cubicInOut,
	cubicOut,
	elasticIn,
	elasticInOut,
	elasticOut,
	expoIn,
	expoInOut,
	expoOut,
	linear,
	quadIn,
	quadInOut,
	quadOut,
	quartIn,
	quartInOut,
	quartOut,
	quintIn,
	quintInOut,
	quintOut,
	sineIn,
	sineInOut,
	sineOut
} from 'svelte/easing';

backIn

Rebound effect on start.

function backIn(t: number): number;

backInOut

Rebound effect on start and end of value range.

function backInOut(t: number): number;

backOut

Rebound effect on end.

function backOut(t: number): number;

bounceIn

Bounce effect on start.

function bounceIn(t: number): number;

bounceInOut

Bounce effect on start and end.

function bounceInOut(t: number): number;

bounceOut

Bounce effect on end.

function bounceOut(t: number): number;

circIn

Circular effect, accelerate on start.

function circIn(t: number): number;

circInOut

Circular effect, accelerate on start, decelerate towards end.

function circInOut(t: number): number;

circOut

Circular effect, decelerate towards end.

function circOut(t: number): number;

cubicIn

Cubic scaling, accelerate on start

function cubicIn(t: number): number;

cubicInOut

Cubic scaling, accelerate on start, decelerate towards end.

function cubicInOut(t: number): number;

cubicOut

Cubic scaling, decelerate towards end.

function cubicOut(t: number): number;

elasticIn

Elastic effect on start.

function elasticIn(t: number): number;

elasticInOut

Elastic effect on start and end.

function elasticInOut(t: number): number;

elasticOut

Elastic effect on end.

function elasticOut(t: number): number;

expoIn

Exponential effect on start.

function expoIn(t: number): number;

expoInOut

Exponential effect on start and end.

function expoInOut(t: number): number;

expoOut

Exponential effect on end.

function expoOut(t: number): number;

linear

Returns value as is.

function linear(t: number): number;

quadIn

Quadratic scaling, accelerate on start.

function quadIn(t: number): number;

quadInOut

Quadratic scaling, accelerate on start, decelerate towards end.

function quadInOut(t: number): number;

quadOut

Quadratic scaling, decelerate towards end.

function quadOut(t: number): number;

quartIn

Quartic scaling, accelerate on start.

function quartIn(t: number): number;

quartInOut

Quartic scaling, accelerate on start, decelerate towards end.

function quartInOut(t: number): number;

quartOut

Quartic scaling, decelerate towards end.

function quartOut(t: number): number;

quintIn

Quintic scaling, accelerate on start.

function quintIn(t: number): number;

quintInOut

Quintic scaling, accelerate on start, decelerate towards end.

function quintInOut(t: number): number;

quintOut

Quintic scaling, decelerate towards end.

function quintOut(t: number): number;

sineIn

Sinusoidal effect, accelerate on start.

function sineIn(t: number): number;

sineInOut

Sinusoidal effect, accelerate on start, decelerate towards end.

function sineInOut(t: number): number;

sineOut

Sinusoidal effect, decelerate towards end.

function sineOut(t: number): number;

Edit this page on GitHub llms.txt