explaingit

janpaepke/scrollmagic

Analysis updated 2026-06-24

14,950TypeScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

Small zero-dependency TypeScript library that wraps IntersectionObserver and ResizeObserver to emit precise scroll-position events and progress values for any element.

Mindmap

mindmap
  root((ScrollMagic))
    Inputs
      Scroll container
      Tracked element
      Zone options
    Outputs
      Enter events
      Leave events
      Progress values
    Use Cases
      Parallax
      Scroll bar progress
      Class toggles
      Lazy load
    Tech Stack
      TypeScript
      IntersectionObserver
      ResizeObserver
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

What do people build with it?

USE CASE 1

Build a horizontal scroll progress bar that fills as the user scrolls down the page

USE CASE 2

Trigger an entry animation in GSAP when a section enters the viewport

USE CASE 3

Toggle a CSS class on a sticky header based on scroll position progress

USE CASE 4

Drive a scroll-linked video timeline that scrubs forward as the user scrolls

What is it built with?

TypeScriptJavaScriptIntersectionObserverResizeObserver

How does it compare?

janpaepke/scrollmagicalibaba/hookstriggerdotdev/trigger.dev
Stars14,95014,95514,915
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyeasymoderate
Complexity2/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

ScrollMagic does not animate anything by itself, you still need GSAP, anime.js, or CSS to actually move pixels.

In plain English

ScrollMagic is a small JavaScript library for building scroll-based interactions on a web page. It tells your code where an element sits relative to the viewport as the user scrolls, and fires events when that position changes. The README describes the current release as version 3, and points users of the older version 2 to a separate branch called v2-stable. It is written in TypeScript, ships with native types, has zero dependencies, and weighs around 6 kilobytes gzipped. The README is careful to set expectations: ScrollMagic does not animate anything by itself. It only gives you precise scroll-position data and events, which you then plug into your own animation, lazy loading, parallax effect, scroll-linked video, behavioural tracking, or anything else. For ready-made scroll animation, the README points readers at GSAP ScrollTrigger, Motion, and anime.js. It also notes that modern CSS has native scroll-driven animations, and positions itself as a complement that adds cross-browser support, callbacks, progress values, and state. Under the hood it is a wrapper around two browser APIs, IntersectionObserver and ResizeObserver, with shared observers, batched animation frames, and single-frame updates to keep performance steady. It works with any scroll container, vertical or horizontal scrolling, server-side rendering, and any framework, since it has no opinions about React, Vue, or vanilla JavaScript. A plugin system is mentioned for extending it. The core idea is that you define two zones: a container zone on the scroll container, and an element zone on the tracked element. A progress value moves from 0 to 1 as the element zone passes through the container zone, and the library fires enter, leave, and progress events along the way. The README gives two common configurations as mental models. Contain is the default when no element is set: progress runs while one fully contains the other, useful for scroll progress bars and parallax. Intersect is the default when an element is set: progress runs while the element overlaps the viewport, useful for enter and leave animations or class toggles. The README ends with a mapping table that shows how the native CSS view-timeline ranges (cover, contain, entry, exit) correspond to ScrollMagic option combinations, and a full options table covering element, elementStart and elementEnd insets, container, containerStart and containerEnd, vertical axis, and others. Installation is a single npm install scrollmagic@next, and a quick-start snippet shows attaching enter, leave, and progress handlers to a tracked element.

Copy-paste prompts

Prompt 1
Install ScrollMagic v3 with npm and write a snippet that fires console logs on enter, leave, and progress for a hero section
Prompt 2
Show me how to combine ScrollMagic v3 with GSAP to scrub a timeline as the user scrolls past an element
Prompt 3
Explain the difference between the Contain and Intersect default configurations in ScrollMagic v3 with one example each
Prompt 4
Give me a ScrollMagic v3 setup for a horizontal scroll container with custom elementStart and elementEnd insets
Prompt 5
Help me migrate an existing ScrollMagic v2 project to v3 and identify the breaking changes

Frequently asked questions

What is scrollmagic?

Small zero-dependency TypeScript library that wraps IntersectionObserver and ResizeObserver to emit precise scroll-position events and progress values for any element.

What language is scrollmagic written in?

Mainly TypeScript. The stack also includes TypeScript, JavaScript, IntersectionObserver.

How hard is scrollmagic to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is scrollmagic for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.