A scene that plays as the page scrolls. The stage holds on screen while the visitor scrolls through it, and each layer is set at moments along a timeline: where it is, how big, and any CSS such as opacity or rotation. Your client drags the moment in the editor and sees the stage at that point.
Download example A zip of block folders for your theme. Needs GCB 1.3.1 or later, and nothing else.
What's in the download
scene/The scene: its layers, how long it runs, its height, and keyframes for the stage itself.
Each folder is an ordinary GCB block: block.json, block.fields.json and render.php, plus a style.css and a view.js where it needs them. There is no build step and no library.
How it's built
The layers and their moments are fields, stored as plain data with the block. The template prints the stage and its layers, and the script reads the keyframes and moves the layers as the page scrolls.
Its fields, from block.fields.json:
| Field | Type |
|---|---|
| Layers | repeater |
| How long it runs | range |
| Height | range |
| Colour behind the layers | color |
| The stage's own keyframes | repeater |
view.js is about 7 KB of plain JavaScript with no animation library. With no script, the stage shows its first moment.
Use it
- Unzip the download.
- Copy
scene/into your theme'sblocks/folder. - Reload the block editor. The block is in the inserter.
That's all of it. You don't register the block: there's no register_block_type() call and nothing to add to functions.php. GCB registers every folder in your theme's blocks/ folder by itself.
It is your block now. Change the markup, the fields or the script to suit the design. The docs cover every field type and marker used here.
More examples: all examples, or download them together as the GCB Kit.