Skip to main content

Adaptive

The adaptive option automatically adjusts the viewport height to match the active panel's height after a panel transition. This is useful for carousels with content of varying heights.

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

// adaptive: false (default)
new Flicking("#flick-fixed", {
  adaptive: false,
  align: "center"
});

// adaptive: true
new Flicking("#flick-adaptive", {
  adaptive: true,
  align: "center"
});

Summary​

Key Options​

OptionTypeDefaultDescription
adaptivebooleanfalseAutomatically adjust viewport height to match the active panel

Comparison by Value​

ValueBehaviorSuitable For
falseViewport height stays fixed (default)Panels with the same height, fixed layouts
trueViewport height adjusts to match the active panelCards with varying heights, variable content

Details​

How Adaptive Works​

When adaptive: true, the viewport height is updated to match the current active panel's height each time a panel transition occurs.

/* CSS for smooth height transitions */
.flicking-viewport {
transition: height 0.3s;
}
  • Relationship with horizontal: adaptive only works with horizontal: true (horizontal mode). It has no effect in vertical mode.

Use Cases​

When to use?
  • adaptive: false: Image galleries, cards of the same size
  • adaptive: true: Text cards of varying lengths, product descriptions, FAQ accordion style

Notes​

Horizontal mode only

adaptive only works when horizontal: true. It has no effect when horizontal: false (vertical mode).

Layout shift

If heights vary significantly, layout shift may occur as content below gets pushed. It is recommended to handle this smoothly with CSS transitions or set a minimum height.

  • horizontal: Horizontal/vertical direction (adaptive is horizontal only)
  • Vertical: Vertical mode (adaptive not supported)