Skip to content

Sticky scroll steps in WordPress

Text scrolls on the left while a visual stays stuck on the right and changes at each step, using CSS sticky and IntersectionObserver. No dependencies, with a vertical stack as fallback.

Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in WordPress

effet-defilement-fixe-etapes-sticky.php
<?php
/**
 * Plugin Name: Forge, Étapes en défilement collant
 * Description: Le texte défile à gauche pendant qu’un visuel reste collé à droite et change à chaque étape, en CSS sticky et IntersectionObserver. Aucune dépendance, repli en pile verticale. Ajoute la composition « Étapes en défilement collant » à l'éditeur de blocs.
 * Version: 1.0.0
 * Requires at least: 6.6
 * Requires PHP: 8.1
 * Author: Forge
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: forge-effet-defilement-fixe-etapes-sticky
 *
pattern.html
<!-- wp:html -->
<section class="efst" aria-labelledby="efst-titre" data-efst>
        <header class="efst__head">
          <p class="efst__eyebrow">Atelier Terre Haute · Céramique</p>
          <h2 class="efst__title" id="efst-titre">Du bloc d’argile au bol sur votre table</h2>
          <p class="efst__intro">Quinze jours et deux cuissons séparent la motte de grès du bol que vous tiendrez entre vos mains. Voici ce qui se passe à l’atelier.</p>
        </header>
        <div class="efst__track">
          <ol class="efst__list" role="list">
          <li class="efst__step" data-efst-step>
            <div class="efst__text" id="efst-etape-1" data-efst-text>
              <div class="efst__copy">
script.js
(() => {
  if (!document.querySelector(".efst")) return;
  for (const root of document.querySelectorAll("[data-efst]")) {
    const steps = [...root.querySelectorAll("[data-efst-step]")];
    const texts = steps.map((step) => step.querySelector("[data-efst-text]"));
    const nav = root.querySelector("[data-efst-nav]");
    const links = [...nav.querySelectorAll("a")];
    const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
    // On a very short or heavily zoomed window the sticky panel would hide the text.
    const tall = window.matchMedia("(min-height: 30rem)");
    let observer = null;
style.css
:root {
  --efst-bg: #f7f1e8;
  --efst-text: #2a1f18;
  --efst-muted: #4a3b30;
  --efst-stage: #efe4d3;
  --efst-line: #d8c8b2;
  --efst-accent: #8a3f1a;
  --efst-on-accent: #fff9f2;
  --efst-clay: #b5734c;
  --efst-clay-raw: #d8b18f;
  --efst-glaze: #2f6f6a;
  --efst-wheel: #6b5a4c;

Free component: copy it freely, including for commercial projects.

Visual effects components in WordPress
  • Cards that fade in as they enter the screen, one after another in each row, without a line of JavaScript and with a static fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A translucent card with a saturated blur whose sharper edge refracts the colourful shapes drifting behind it, with an opaque fallback when transparency is reduced.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A help block shaped like a conversation: bubbles, three animated typing dots and clickable quick replies that show your answers to frequent questions, frozen under prefers-reduced-motion.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A paragraph whose words turn from grey to full ink, one by one, as the page scrolls, in pure CSS with a plain-text fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Four offset, translucent sine waves gently roll along the bottom of a section, each at its own pace.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component