Skip to the content

Leaflet

A section that arrives folded, cover up, and that the scroll opens as a hand would.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    Three things belong to the page rather than to the component: no parent of the section may cut its overflow with overflow: hidden, which stops the block from pinning, so use overflow-x: clip where a parent has to cut; the sheet itself takes no background, overflow, filter or opacity, which would flatten the fold; and the panels sit in one row or one column, never a grid of both.
  3. Add custom JS

  4. Tune it

    Custom attributes
    Select the section on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-leaflet Marks the section the page scrolls through while the leaflet opens. It takes no value: leave the value field empty. That section is what the stylesheet makes taller by the scroll the unfolding takes, and what carries the settings. Without it on any element of the page, the embed marks the block holding the screen.
    data-leaflet-pin Marks the block that stays on screen, a child of the section: it holds the sheet, and gives the panels their perspective. It takes no value. Without it the engine takes the first block of the section. [ Optional ]
    data-leaflet-sheet Marks the sheet, the grid or flex row whose children are the panels. It takes no value, and no background, overflow, filter or opacity of its own. Without it the engine takes the last block of the block that stays on screen. [ Optional ]
    data-leaflet-panel Marks a panel, a child of the sheet: two to six of them, in one row or one column, each with any content. It takes no value. Add one, take one out, and the fold follows. Without it on any child, every child of the sheet is a panel. [ Optional ]
    data-leaflet-cover Marks the cover, a child of the sheet: it is laid on the back that ends on top of the folded leaflet and only shows while it is folded. It takes no value. Left out when an accordion of three or five panels ends face up; without the script and under reduced motion it is an ordinary child of the sheet. [ Optional ]
    data-leaflet-state Written by the engine on the section: pinned when the open sheet fits the screen, flowing when it unfolds in the flow of the page, still under reduced motion. Never written by hand; it is what the stylesheet reads to pin the block and give it depth. [ Optional ]
    data-leaflet-axis Written by the engine on the section: x when the panels sit side by side, y when they sit one under the other. Never written by hand; the paint of the creases turns with it. [ Optional ]
    data-leaflet-open Written by the engine on the section while the sheet lies flat. Never written by hand. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same section. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-leaflet-paper #f4ece0 Colour of the face of the sheet. Left at its default, each panel keeps the background its own class gives it; changed, every panel is painted with it. Options: any CSS colour. To colour one panel only, leave this alone and give that panel a background in its own class.
    data-leaflet-back #e9dfce Colour of the back of the sheet, the side that shows while a panel turns. Options: any CSS colour. A shade under paper reads as the unprinted side; the same colour reads as a sheet printed on both sides.
    data-leaflet-shadow #050302 Colour of every shadow: on the surface, in the folds, and on a face turned away from the light. Options: any CSS colour. A dark shade of the surface colour sits better than pure black.
    data-leaflet-fold accordion How the sheet is folded: accordion, roll or gate. Options: accordion folds one way then the other, and opens two panels at a time, as a tent that lies down; roll wraps every panel the same way and unrolls them one by one; gate closes the two ends on the middle like doors and opens them together. A gate needs three panels at least.
    data-leaflet-opens forward End the sheet opens towards: forward or backward. A gate opens from its middle and ignores it. Options: forward keeps the first panel down and opens towards the last, to the right or downwards; backward keeps the last panel down and opens towards the first.
    data-leaflet-length clamp(1500px, 320vh, 4400px) Scroll the unfolding takes while the sheet is pinned, any CSS length. Not read when the open sheet is taller than the screen and unfolds in the flow of the page.
    data-leaflet-smooth 0.18 Time the sheet takes to catch the scroll, in seconds.
    data-leaflet-overlap 0.3 Share of a fold played together with the next one, 0 to 1.
    data-leaflet-perspective clamp(1800px, 160vw, 3000px) Distance of the eye from the surface, any CSS length.
    data-leaflet-tilt 18 Lean of the folded sheet away from the eye, in degrees, while it is pinned. It comes back to 0 as the sheet lies flat.
    data-leaflet-lift clamp(14px, 2.2vw, 40px) Height the leaflet is held over the surface while it is handled, any CSS length. It lands as it lies flat.
    data-leaflet-thickness 1.5 Thickness of one layer of the folded stack, in px. It is the room each crease leaves for the layers it wraps.
    data-leaflet-light 0.5 Strength of the light on the panels, 0 to 1: how far a face brightens towards the light and darkens away from it.
    data-leaflet-depth 0.5 Strength of the shadows, 0 to 1: the one on the surface and the one a closing fold lays on a face.
    data-leaflet-crease 0.5 Mark the folds leave on the flat sheet, 0 to 1: a hairline on each folded edge and a shade in each valley.
    data-leaflet-grain 0.5 Grain of the paper, 0 to 1.
    data-leaflet-pool 0.5 Light on the surface around the sheet, 0 to 1. A shadow only shows on a surface that is lit.

What it does

Leaflet is a scroll animation for Webflow and vanilla JavaScript, with no library. Also called paper fold animation on scroll, 3D fold scroll animation or unfolding brochure effect.

A section that arrives folded, cover up, and that the scroll opens as a hand would. The sheet is the page's own grid: two to six panels in one row, each with any content. The engine measures them where the CSS puts them and folds the row along the edges the panels share, as paper folds: an accordion whose panels swing over two by two and stand as a tent before they lie down, a roll that unrolls one panel at a time, or a gate whose two doors open together. Every panel is hinged on its crease in real perspective, the stack has a thickness so no panel passes through another, and each panel has a back made of paper that shows while it turns. The light is one fixed direction: a face turned towards it brightens, a face turned away darkens, a closing fold lays its shadow from the crease, and the whole sheet casts a soft shadow on the surface under it, projected along the same light. A cover block is printed on the back that ends on top of the folded leaflet; on a gate it is shared by the two doors. Once flat, the transforms come off: the section is the grid it was written as, the text selects, the links work, and the creases stay faintly marked, as on paper that has been folded. Panels laid one under the other, the layout of a phone, fold and unfold downwards, in the flow of the page instead of pinned. Eased towards the scroll and reversible. No library: the hold is sticky positioning and the place is read from the layout, so it follows the browser's own scroll and a smooth scroll library alike. Under reduced motion and without the script, the flat sheet. Pattern type scroll unfold, 3D fold, paper.

Updated

Questions

Mark a section data-leaflet, the block that stays on screen data-leaflet-pin, the row inside it data-leaflet-sheet and each of its two to six children data-leaflet-panel. The sheet is your own grid or flex row: the engine reads where the layout puts the panels and folds along the edges they share. data-leaflet-length is the scroll the unfolding takes.

No library at all. The hold is CSS sticky positioning, the place in the scroll is read from the layout, and each panel is hinged on its crease by a matrix3d in real perspective. It follows the browser's own scroll and a smooth scroll library alike.

Three, set with data-leaflet-fold. accordion, the default, swings the panels over two by two and stands them as a tent before they lie down; roll unrolls one panel at a time; gate opens two doors together. data-leaflet-opens picks the end the sheet opens towards, and data-leaflet-overlap, 0.3 by default, how much of a fold plays with the next one.

Yes. Once the sheet lies flat the transforms come off: the section is the grid it was written as, the text selects and the links work, with the creases left faintly marked. data-leaflet-crease sets that mark, and at 0 nothing shows the sheet was ever folded.

Panels laid one under the other fold and unfold downwards: the direction is read from the layout, so a media query that stacks the panels is all it takes. A sheet taller than the screen is not pinned, it starts folded at the top of its place and each panel comes down as the page reaches it. Under reduced motion and without the script the page shows the flat sheet.