Skip to main content

Easing

The easing option sets the animation curve for panel movement. Specified as a function that takes a progress value (0-1) and returns the actual movement ratio.

import Flicking from "@egjs/flicking";
import "@egjs/flicking/dist/flicking.css";
import "./styles.css";

// Easing functions
const linear = x => x;
const easeOutCubic = x => 1 - (1 - x) ** 3;
const easeInOutQuad = x => (x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2);

// linear
new Flicking("#flick-linear", {
  easing: linear,
  duration: 800,
  align: "center"
});

// easeOutCubic (default)
new Flicking("#flick-ease-out", {
  easing: easeOutCubic,
  duration: 800,
  align: "center"
});

// easeInOutQuad
new Flicking("#flick-ease-in-out", {
  easing: easeInOutQuad,
  duration: 800,
  align: "center"
});

Summary​

Key Options​

OptionTypeDefaultDescription
easing(x: number) => numbereaseOutCubicAnimation curve function

Comparison by Value​

FunctionBehaviorSuitable For
linearMoves at constant speedMechanical feel, progress indicators
easeOutCubicStarts fast, ends slowNatural deceleration, general UI
easeInOutQuadSlow, fast, then slowSmooth transitions, presentations

Details​

Easing Function Format​

An easing function takes a progress value between 0 and 1 and returns the actual movement ratio.

// linear: constant speed
const linear = x => x;

// easeOutCubic: starts fast, ends slow (default)
const easeOutCubic = x => 1 - Math.pow(1 - x, 3);

// easeInOutQuad: accelerates then decelerates
const easeInOutQuad = x => x < 0.5
? 2 * x * x
: 1 - Math.pow(-2 * x + 2, 2) / 2;

Key Easing Patterns​

  • linear: Input = output. Moves at constant speed
  • easeOut: Fast at the beginning, slow at the end (deceleration). Natural stopping
  • easeIn: Slow at the beginning, fast at the end (acceleration). Emphasizes the start
  • easeInOut: Accelerates then decelerates. Smooth transitions
  • Relationship with duration: duration determines the animation time, while easing determines the velocity change pattern during that time. Combine both to create various effects.

Use Cases​

When to use?
  • linear: Loading progress indicators, mechanical UI
  • easeOut (default): General carousels, natural snapping
  • easeInOut: Presentations, onboarding, emphasizing smooth transitions

Notes​

Easing function rules

The easing function must satisfy f(0) = 0 and f(1) = 1. Breaking this rule will cause the animation to malfunction.

External References​