Skip to main content

Perspective

Applies 3D perspective rotation and scale transformation effects based on panel position.

import Flicking from "@egjs/flicking";
import { Perspective } from "@egjs/flicking-plugins";
import "@egjs/flicking/dist/flicking.css";
import "./styles.css";

const COLORS = ["#e74c3c", "#3498db", "#2ecc71", "#f39c12", "#9b59b6"];

const camera = document.querySelector(".flicking-camera");
COLORS.forEach((color, i) => {
  const panel = document.createElement("div");
  panel.className = "flicking-panel";
  panel.style.background = color;
  panel.textContent = i + 1;
  camera.appendChild(panel);
});

const flicking = new Flicking("#flick", {
  circular: true,
  align: "center"
});

flicking.addPlugins(new Perspective({ rotate: 1, perspective: 1000 }));

Summary​

Key Options​

OptionTypeDefaultDescription
rotatenumber1Rotation intensity. Positive values rotate right panels inward, negative values rotate outward
scalenumber2Scale transformation intensity
perspectivenumber1000CSS perspective value (px). Smaller values produce stronger distortion

Details​

How It Works​

The Perspective plugin automatically applies rotateY and scale transformations based on each panel's visible ratio. Panels closer to the center face forward, while panels farther away appear rotated.

Usage​

import { Perspective } from "@egjs/flicking-plugins";

// Basic usage
flicking.addPlugins(new Perspective({ rotate: 1, perspective: 1000 }));

// Strong distortion
flicking.addPlugins(new Perspective({ rotate: -1, scale: 2, perspective: 600 }));

Notes​

Caution
  • Using with circular: true enables a seamless 3D rotation effect.
  • If there are too few panels, empty spaces may appear during circulation. At least 4-5 panels are recommended.