Components/FoldPage

FoldPage

Interactive 3D multi-panel fold and paper corner peel effects.

VerifiedSince 0.9.5

Usage

Multi-Panel Fold

TxFoldPage folds and unfolds a multi-panel surface in 3D perspective using either a concertina accordion or staggered gate tri-fold layout, with horizontal/vertical axes, pointer momentum drag, and click toggling.

Loading demo...

Corner Peel

TxFoldCorner uses perpendicular-bisector polygon clipping and an exact 2D reflection matrix to curl and peel back any corner of a card, exposing an interactive #under layer underneath.

Loading demo...

Combined Usage

Nest TxFoldCorner inside a named #panel-<id> slot of TxFoldPage to pair a 3D brochure spread with a peelable metadata card.

Loading demo...

Best Practices

  • Keep the default surface="refraction" so folded facets and peeled sheets match TuffEx's light, dark, and high-contrast surfaces.
  • In gate mode, wing panels automatically render a 180-degree rotated #cover backface with an opaque backing so inner content never bleeds through when closed.
  • When nesting TxFoldCorner or another draggable control inside TxFoldPage, add @pointerdown.stop and @click.stop on the inner element so pointer gestures do not bubble to the outer fold container.
  • Pass rest-peel="0" when a sheet should sit completely flat at rest; the #under layer automatically stays inert and aria-hidden until peeled past the threshold.
  • Use size (xs, sm, md, lg) or an explicit container height; vertical tri-folds work best at md or lg so each panel retains comfortable vertical space.

API Reference

TxFoldPage

Props

NameTypeDefaultDescription
modelValuebooleanfalseWhether the fold spread is open; bind with v-model.
progressnumberundefinedControlled continuous openness (0 to 1); bind with v-model:progress.
panelsFoldPagePanel[]undefinedPanel definitions; falls back to count numbered panels when omitted.
countnumber3Number of panels when panels is omitted (minimum 2).
direction'horizontal' | 'vertical''horizontal'Axis along which panels fold.
foldStyle'accordion' | 'gate''accordion'Concertina accordion or staggered cover-wing tri-fold.
foldAnglenumber68 (accordion), 172 (gate)Closed fold angle in degrees.
perspectivenumber1400CSS 3D perspective distance in px.
creaseOpacitynumber0.28Crease shadow and highlight intensity (0 to 1).
surfaceBaseSurfaceMode'refraction'Surface mode forwarded to TxBaseSurface.
surfaceColorstring''Optional surface tint color; follows the theme by default.
surfaceOpacitynumber0.78 (accordion), 0.94 (gate)Surface base opacity (0 to 1).
size'xs' | 'sm' | 'md' | 'lg''md'Height and padding preset.
radiusnumber16Outer corner radius in px.
draggablebooleantrueAllows pointer dragging to scrub fold progress.
clickToTogglebooleantrueToggles open state on non-interactive surface clicks.
stiffnessnumber220Spring stiffness for settle animation.
dampingnumber24Spring damping for settle animation.
disabledbooleanfalseDisables pointer and keyboard interaction.
ariaLabelstring'Fold page'Accessible label on the fold region.
labelsFoldPageLabelsEnglish defaultsAccessible labels for the toggle button (expand, collapse, toggle).

Events

EventParamsDescription
update:modelValue(value: boolean)Emits when open state changes.
update:progress(progress: number)Emits continuous openness (0 to 1) during drags or uncontrolled motion.
change(value: boolean)Emits when the boolean state actually changes.
fold-start(to: boolean)Emits when a fold transition or drag begins.
fold-end(value: boolean)Emits when the fold settles at its target state.

Slots

SlotPropsDescription
panel{ panel, index, count, progress, angle, open }Shared slot for rendering any panel.
panel-<index>{ panel, index, count, progress, angle, open }Per-index panel override.
panel-<id>{ panel, index, count, progress, angle, open }Per-panel.id override.
cover{ open, progress, toggle }Front cover backface of the primary wing in gate mode.

Exposed Methods

MethodTypeDescription
open()() => voidUnfolds the panels flat.
close()() => voidFolds the panels closed.
toggle()() => voidToggles between folded and flat states.
setProgress(value)(value: number) => voidJumps immediately to a progress value (0 to 1).

TxFoldCorner

Props

NameTypeDefaultDescription
modelValuebooleanfalseWhether the corner is peeled open; bind with v-model.
progressnumberundefinedControlled peel depth (0 to 1); bind with v-model:progress.
corner'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''bottom-right'Corner from which the sheet peels.
trigger'hover' | 'click' | 'drag' | 'hover-drag''hover-drag'Interaction trigger mode.
restPeelnumber0.12Subtle dog-ear peel amount at rest (0 to 1).
hoverPeelnumber0.28Corner curl amount on pointer hover (0 to 1).
openPeelnumber0.84Target peel depth when opened (0 to 1).
surfaceBaseSurfaceMode'refraction'Surface mode forwarded to TxBaseSurface.
surfaceColorstring''Optional surface tint color; follows the theme by default.
surfaceOpacitynumber0.96Opacity of the front sheet and curled flap back.
size'xs' | 'sm' | 'md' | 'lg''md'Container height and padding preset.
radiusnumber16Outer corner radius in px.
creaseOpacitynumber0.26Dynamic flap drop-shadow and crease sheen strength (0 to 1).
stiffnessnumber2402D spring stiffness.
dampingnumber262D spring damping.
disabledbooleanfalseDisables hover, drag, click, and keyboard peeling.
ariaLabelstring'Fold corner'Accessible label on the corner region.
labelsFoldCornerLabelsEnglish defaultsAccessible labels for the corner handle (peel, flatten, toggle).

Events

EventParamsDescription
update:modelValue(value: boolean)Emits when peeled state changes.
update:progress(progress: number)Emits continuous peel progress (0 to 1).
change(value: boolean)Emits when peeled state actually changes.
peel-start(to: boolean)Emits when peeling or flattening begins.
peel-end(value: boolean)Emits when the corner settles.

Slots

SlotPropsDescription
default{ progress, peeled, corner, angleDeg, toggle }Front sheet content.
under{ progress, peeled, corner, angleDeg, toggle }Underlying content revealed beneath the peel.
reveal{ progress, peeled, corner, angleDeg, toggle }Alias for the under slot.
flap{ progress, peeled, corner, angleDeg, toggle }Underside content of the curled paper flap.

Exposed Methods

MethodTypeDescription
peel()() => voidPeels the corner open.
flatten()() => voidReturns the corner to rest.
toggle()() => voidToggles between peeled and resting states.
setProgress(value)(value: number) => voidJumps immediately to a peel depth (0 to 1).

Overview

  • TxFoldPage derives continuous 3D panel translations and hinge angles from measured container bounds so seams remain locked across the full fold sweep, while gate mode staggers outer wings with explicit Z separation to avoid Z-fighting.
  • TxFoldCorner constructs the perpendicular bisector between the corner origin and the active tip, splits the rectangle via Sutherland-Hodgman polygon clipping, and reflects the flap using a 2D reflection matrix so the crease line stays pinned to the sheet.
  • While TxFoldCorner sits near rest (progress < 0.08), the #under layer carries inert and aria-hidden="true" so concealed controls stay out of the keyboard Tab order.
  • Both components honor prefers-reduced-motion: reduce, snapping immediately to the target state without running the frame loop.

Technologies

  • Spring physics run on stepSpring, createFrameLoop, and projectMomentum from @talex-touch/tuffex/utils, sleeping as soon as motion settles.
  • Framework-free 3D layout and 2D reflection geometry live in geometry.ts (computeFoldPageLayout, computeCornerPeelGeometry, clipPolygonHalfPlane).
  • Source: packages/tuffex/packages/components/src/fold-page/.
查看源码
packages/tuffex/packages/components/src/fold-page/index.ts