explaingit

russellsamora/scrollama

5,968HTMLAudience · developerComplexity · 2/5Setup · easy

TLDR

A small JavaScript library for building scrollytelling web experiences where page content changes as a reader scrolls, using efficient IntersectionObserver instead of costly scroll event listeners.

Mindmap

mindmap
  root((repo))
    What it does
      Scroll-triggered content
      Scrollytelling helper
    How it works
      IntersectionObserver
      Step callbacks
      Progress tracking
    Features
      Debug visual guides
      Auto resize handling
      Per-step offsets
    Use cases
      Data journalism
      Interactive stories
      Sticky graphics
    Tech stack
      JavaScript
      npm package
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a data story where a chart updates as a reader scrolls through labeled text sections

USE CASE 2

Create a sticky graphic that stays fixed on screen while explanatory text scrolls past it

USE CASE 3

Trigger smooth animations as users scroll through content steps using progress callbacks

USE CASE 4

Add scrollytelling to any JavaScript framework or plain HTML page with minimal setup

Tech stack

JavaScriptIntersectionObserver APInpm

Getting it running

Difficulty · easy Time to first run · 5min
No license information mentioned in the explanation.

In plain English

Scrollama is a small JavaScript library that makes it easier to build "scrollytelling" experiences on the web. Scrollytelling is the technique where content on the screen changes or reacts as a reader scrolls down the page. You see it often in long-form journalism and interactive data stories where a chart updates or an animation plays as you move through the text. Under the hood, Scrollama uses a browser feature called IntersectionObserver to watch when certain page sections come into view. Older approaches listened to every scroll event the browser fired, which could cause performance problems on large pages. The IntersectionObserver approach only fires when an element actually crosses a threshold you define, so it puts less strain on the browser. You set up the library by pointing it at the page sections you want to treat as steps, then you provide callback functions that run when a reader enters or exits each step. You can also track how far through a step the reader has scrolled, called progress, which lets you animate things smoothly rather than snapping between states. There is a debug mode that draws visual guides on the page so you can see exactly where the trigger points sit. Version 3 added a built-in resize observer, so the library adjusts automatically when a browser window is resized without you needing to call a manual resize function. You can also set a custom trigger offset on individual steps using a data attribute on the HTML element, which is useful when different sections of a page need to activate at different scroll positions. Installation is either a script tag from a CDN or a standard npm package import. The library works with any JavaScript framework or with no framework at all. The examples in the repository cover common patterns such as a sticky graphic that stays fixed to the side of the text while the reader scrolls, a full-screen overlay layout, and a mobile-friendly configuration.

Copy-paste prompts

Prompt 1
Using scrollama, set up a page where a fixed SVG chart updates its data as the user scrolls through 5 labeled text sections. Show me the complete JavaScript setup.
Prompt 2
My scrollama sticky-graphic layout breaks on mobile. Help me configure per-step scroll offsets and the built-in resize observer to fix it.
Prompt 3
Animate a CSS transform property smoothly using scrollama's progress callback as users scroll through a step. Show me the complete JavaScript code.
Open on GitHub → Explain another repo

← russellsamora on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.