Web Dev Academy Animation & scroll ยท Locomotive Scroll & ScrollMagic Tool 27 / 64
Animation & scroll

Locomotive Scroll & ScrollMagic

Two scroll-orchestration tools. Locomotive Scroll combines smooth scrolling with declarative data-scroll parallax and in-view detection. ScrollMagic pioneered the "scenes-on-scroll" pattern for pinning and scrubbing.

Demo 01

Parallax with data-scroll-speed

The real Locomotive Scroll runs on the panel below. Each block carries data-scroll attributes โ€” the emoji layers move at different data-scroll-speed values, creating depth as you scroll inside the box.

Parallax block 1
๐Ÿš‚
Block 2 โ€” moves opposite
โ›ฐ๏ธ
Block 3 โ€” layered depth
๐ŸŒฒ
Block 4 โ€” keep scrolling
โœจ

โ†‘ scroll inside the box ยท layers shift at different speeds via Locomotive Scroll

const scroll = new LocomotiveScroll({
  el: container, smooth: true
});
<!-- markup -->
<div data-scroll data-scroll-speed="4">๐Ÿš‚</div>
Demo 02

In-view detection

Locomotive also fires events when elements enter the viewport. Below, a real Locomotive instance toggles an is-inview state on cards as they scroll past โ€” fading and lifting them in.

โ†“ scroll โ†“
Reveal card A
Reveal card B
Reveal card C
Note

About ScrollMagic

ScrollMagic is the older sibling of this family. It introduced the idea of a Scene with a trigger element, a duration, and a tween (often handed to GSAP) that's scrubbed as you scroll โ€” plus pinning elements in place. Today most of that role has been absorbed by GSAP's own ScrollTrigger (see the GSAP page) and by Locomotive Scroll. The pattern below is what a ScrollMagic scene expresses:

const controller = new ScrollMagic.Controller();
new ScrollMagic.Scene({ triggerElement: "#hero", duration: 300 })
  .setTween("#hero", { scale: 0.6, opacity: 0.4 }) // scrubbed
  .setPin("#hero")                                // pin in place
  .addTo(controller);
i
The parallax and in-view demos use the real Locomotive Scroll 4.1.4, loaded (CSS + JS) from cdn.jsdelivr.net/npm/locomotive-scroll, scoped to inner data-scroll-container panels. ScrollMagic is presented as a code explainer (not run live) because its pinning model targets full-page scroll; its modern equivalent, GSAP ScrollTrigger, runs for real on the GSAP page. Page chrome is the shared CSS shell.

โ†‘ All 64 tools