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.
- JavaScript
- React
- Vue@3
Summary
Key Options
| Option | Type | Default | Description |
|---|---|---|---|
adaptive | boolean | false | Automatically adjust viewport height to match the active panel |
Comparison by Value
| Value | Behavior | Suitable For |
|---|---|---|
false | Viewport height stays fixed (default) | Panels with the same height, fixed layouts |
true | Viewport height adjusts to match the active panel | Cards 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;
}
Related Options
- Relationship with horizontal:
adaptiveonly works withhorizontal: 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.
Related Links
Related Options
horizontal: Horizontal/vertical direction (adaptive is horizontal only)
Related Demos
- Vertical: Vertical mode (adaptive not supported)