Skip to main content

Nested

The nested option transfers control to the parent Flicking when the child Flicking reaches its boundary. Provides a natural UX for same-direction nested Flicking instances.

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

// nested: false
new Flicking("#outer-false", { align: "center" });
document.querySelectorAll("#outer-false .inner-viewport").forEach(el => {
  new Flicking(el, { nested: false, align: "center", bound: true });
});

// nested: true
new Flicking("#outer-true", { align: "center" });
document.querySelectorAll("#outer-true .inner-viewport").forEach(el => {
  new Flicking(el, { nested: true, align: "center", bound: true });
});

Summary

Key Options

OptionTypeDefaultDescription
nestedbooleanfalseTransfer control to parent when reaching boundary

Comparison by Value

ValueBehaviorSuitable For
falseStops at inner boundary, parent does not move (default)Independent inner carousels
trueTransfers control to parent after reaching inner boundarySame-direction nested carousels

Details

How Nested Works

When a child Flicking with nested: true reaches the first or last panel and the user continues to drag in the same direction, the parent Flicking moves instead.

// Parent Flicking
<Flicking>
<div className="panel">
{/* Child Flicking - nested enabled */}
<Flicking nested={true} bound={true}>
<div>Inner 1</div>
<div>Inner 2</div>
</Flicking>
</div>
</Flicking>

When Is It Needed?

  • Needed: When parent and child are in the same direction (both horizontal: true or both false)
  • Not needed: When parent and child are in different directions (one horizontal, one vertical) - they are automatically distinguished
  • Relationship with bound: Using bound: true together makes the inner boundary clearer, resulting in more natural nested behavior.
  • Relationship with horizontal: If the parent/child have different horizontal values, it works naturally without the nested option.

Use Cases

When to use?
  • nested: true: Product carousels by category (outer: categories, inner: products)
  • nested: false: Inner carousels that need to operate independently

Notes

Set on the child Flicking

The nested option is set on the child (inner) Flicking. There is no need to set it on the parent.

Not needed for different directions

If the parent is horizontal and the child is vertical (or vice versa), it works naturally without the nested option.

  • bound: Boundary restriction (recommended with nested)
  • horizontal: Movement direction
  • Bound: Boundary restriction mode
  • Vertical: Vertical mode (different direction combination)