Skip to main content

Coverflow

Use indexProgress from the Reactive API to apply 3D rotation and scaling effects that create an album-art style coverflow interface.

import Flicking, { connectFlickingReactiveAPI } from "@egjs/flicking";
import "@egjs/flicking/dist/flicking.css";
import "./styles.css";

// Capture panel references BEFORE Flicking init (circular mode may modify DOM)
const panels = document.querySelectorAll(".flicking-panel");
const LENGTH = 5;

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

const update = value => {
  panels.forEach((panel, index) => {
    const childProgress = ((index - value + LENGTH * 1.5) % LENGTH) - LENGTH * 0.5;
    const scale = Math.max(0, 0.9 - Math.abs(childProgress) * 0.2);

    panel.style.transformOrigin = `${50 - childProgress * 50}% 50%`;
    panel.style.transform = `rotateY(${-childProgress * 50}deg) scale(${scale})`;
  });
};

// Apply initial state and subscribe to changes
update(reactiveAPI.indexProgress);
reactiveAPI.subscribe("indexProgress", update);

Summary

Key API

PropertyTypeDescription
indexProgressnumberCamera position as a fractional panel index
useFlickingReactiveAPIHook (React)Subscribe to reactive state in React
connectFlickingReactiveAPIFunction (Vanilla)Subscribe to reactive state in Vanilla JS

Effect Mapping

Panel PositionrotateYscaletransformOrigin
Current (childProgress ~ 0)0deg0.950% 50%
Adjacent (childProgress ~ +/-1)-/+50deg0.7shifted toward center
Far (childProgress ~ +/-2)-/+100deg0.5shifted toward center

Details

What is indexProgress?

indexProgress represents the current camera position as a fractional panel index. For example, 2.5 means the camera is exactly halfway between panel 2 and panel 3. It updates in real-time during drag, enabling smooth visual transitions.

How It Works

For circular mode, each panel's childProgress is calculated with wrapping:

const childProgress = (index - indexProgress + length * 1.5) % length - length * 0.5;

This value drives three CSS transform properties:

  • rotateY: Panels rotate around the Y-axis, angling away from center
  • scale: Panels shrink as they move further from center
  • transformOrigin: Shifts to create a natural perspective pivot point
  • circular: true: Essential for seamless coverflow looping without dead ends.
  • align: "center": Places the active panel at the visual center of the coverflow.

Use Cases

When to use
  • Album / portfolio gallery
  • Product showcase
  • Media player UI

Important Notes

Note
  • Set CSS perspective on the viewport and transform-style: preserve-3d on the camera for 3D effects to render.
  • Use at least 5 panels to avoid gaps when using circular mode.