FoldPage
Interactive 3D multi-panel fold and paper corner peel effects.
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
gatemode, wing panels automatically render a 180-degree rotated#coverbackface with an opaque backing so inner content never bleeds through when closed. - When nesting
TxFoldCorneror another draggable control insideTxFoldPage, add@pointerdown.stopand@click.stopon 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#underlayer automatically staysinertandaria-hiddenuntil peeled past the threshold. - Use
size(xs,sm,md,lg) or an explicit container height; vertical tri-folds work best atmdorlgso each panel retains comfortable vertical space.
API Reference
TxFoldPage
Props
| Name | Type | Default | Description |
|---|---|---|---|
modelValue | boolean | false | Whether the fold spread is open; bind with v-model. |
progress | number | undefined | Controlled continuous openness (0 to 1); bind with v-model:progress. |
panels | FoldPagePanel[] | undefined | Panel definitions; falls back to count numbered panels when omitted. |
count | number | 3 | Number 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. |
foldAngle | number | 68 (accordion), 172 (gate) | Closed fold angle in degrees. |
perspective | number | 1400 | CSS 3D perspective distance in px. |
creaseOpacity | number | 0.28 | Crease shadow and highlight intensity (0 to 1). |
surface | BaseSurfaceMode | 'refraction' | Surface mode forwarded to TxBaseSurface. |
surfaceColor | string | '' | Optional surface tint color; follows the theme by default. |
surfaceOpacity | number | 0.78 (accordion), 0.94 (gate) | Surface base opacity (0 to 1). |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Height and padding preset. |
radius | number | 16 | Outer corner radius in px. |
draggable | boolean | true | Allows pointer dragging to scrub fold progress. |
clickToToggle | boolean | true | Toggles open state on non-interactive surface clicks. |
stiffness | number | 220 | Spring stiffness for settle animation. |
damping | number | 24 | Spring damping for settle animation. |
disabled | boolean | false | Disables pointer and keyboard interaction. |
ariaLabel | string | 'Fold page' | Accessible label on the fold region. |
labels | FoldPageLabels | English defaults | Accessible labels for the toggle button (expand, collapse, toggle). |
Events
| Event | Params | Description |
|---|---|---|
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
| Slot | Props | Description |
|---|---|---|
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
| Method | Type | Description |
|---|---|---|
open() | () => void | Unfolds the panels flat. |
close() | () => void | Folds the panels closed. |
toggle() | () => void | Toggles between folded and flat states. |
setProgress(value) | (value: number) => void | Jumps immediately to a progress value (0 to 1). |
TxFoldCorner
Props
| Name | Type | Default | Description |
|---|---|---|---|
modelValue | boolean | false | Whether the corner is peeled open; bind with v-model. |
progress | number | undefined | Controlled 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. |
restPeel | number | 0.12 | Subtle dog-ear peel amount at rest (0 to 1). |
hoverPeel | number | 0.28 | Corner curl amount on pointer hover (0 to 1). |
openPeel | number | 0.84 | Target peel depth when opened (0 to 1). |
surface | BaseSurfaceMode | 'refraction' | Surface mode forwarded to TxBaseSurface. |
surfaceColor | string | '' | Optional surface tint color; follows the theme by default. |
surfaceOpacity | number | 0.96 | Opacity of the front sheet and curled flap back. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Container height and padding preset. |
radius | number | 16 | Outer corner radius in px. |
creaseOpacity | number | 0.26 | Dynamic flap drop-shadow and crease sheen strength (0 to 1). |
stiffness | number | 240 | 2D spring stiffness. |
damping | number | 26 | 2D spring damping. |
disabled | boolean | false | Disables hover, drag, click, and keyboard peeling. |
ariaLabel | string | 'Fold corner' | Accessible label on the corner region. |
labels | FoldCornerLabels | English defaults | Accessible labels for the corner handle (peel, flatten, toggle). |
Events
| Event | Params | Description |
|---|---|---|
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
| Slot | Props | Description |
|---|---|---|
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
| Method | Type | Description |
|---|---|---|
peel() | () => void | Peels the corner open. |
flatten() | () => void | Returns the corner to rest. |
toggle() | () => void | Toggles between peeled and resting states. |
setProgress(value) | (value: number) => void | Jumps immediately to a peel depth (0 to 1). |
Overview
TxFoldPagederives continuous 3D panel translations and hinge angles from measured container bounds so seams remain locked across the full fold sweep, whilegatemode staggers outer wings with explicit Z separation to avoid Z-fighting.TxFoldCornerconstructs 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
TxFoldCornersits near rest (progress < 0.08), the#underlayer carriesinertandaria-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, andprojectMomentumfrom@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