MCPcopy Index your code
hub / github.com/basementstudio/scrollytelling

github.com/basementstudio/scrollytelling @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
83 symbols 208 edges 58 files 0 documented · 0% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

BSMNT Scrollytelling

BSMNT Scrollytelling is a library for creating Scrollytelling animations. It's powered by GSAP ScrollTrigger, but abstracts away some things to make it work better with React.

Frame 7


👇 New documentation here! 👇


Installation

To get started, we'll need the @bsmnt/scrollytelling package, as well as the required peer dependency: GSAP.

yarn add @bsmnt/scrollytelling gsap

Why

At basement, we've built a bunch of websites that use scroll animations. Over the years, we faced some issues that required solutions that we copy-pased throughout different project. We decided to build a library to share how we build these with the world.

Challenges we faced

  • Needed a deep understanding of how GSAP works with ScrollTrigger.
  • Needed to be careful about running animations inside useEffect and then cleaning them up.
  • Couldn’t think of scroll animations in terms of a start and an end, so it was hard to fire up animations at the exact scroll progress we needed to.

What

We aimed at componentizing a way of building scroll animations that could:

  • ✅ Provide sensible defaults for scroll animations, such as scrub: true, and ease: 'linear'.
  • ✅ Take care of component mounting and unmounting.
  • ✅ Create animations with absolute positioning defined by a start and an end, instead of a time-based duration.

As an added benefit, going "component-based" allowed us to:

  • ✅ Improve compatibility with React Server Components: our components definitely 'use client', but not necessarily the parents or children of our components.
  • ✅ Compose animations at every level of the tree, as it all works with React Context.

A simple example of how this works:

117 (1)

Exports

  • Root: Creates timeline and scrollTrigger, provides React Context.
  • Animation: Appends an animation to the timeline. Receives a tween prop that will control how the animation behaves.
  • Waypoint: Runs a callback or tween at a specific point in the timeline. Can also receive a label prop, that will create a GSAP label at that position.
  • RegisterGsapPlugins: Registers custom GSAP plugins, if you need them for a specific use case.
  • Parallax: Helper to create a simple parallax.
  • ImageSequenceCanvas: Helper to create a simple image sequence animation.
  • useScrollytelling: Context consumer. Returns the timeline.
  • useScrollToLabel: Scrolls to the label name you pass. Labels can be added with the Waypoint component.

Demo

We did a small demo to showcase this library in action. This is the best place to see how the library works in a real world scenario. Check it out:

Examples

Troubleshooting

"My simple animation is not doing anything on scroll"

Please check your start and end values for your Root component. A typical issue comes when:

  1. your animation "starts when the start of the scroller hits the start of the viewport",
  2. your animation "ends when the bottom of the scroller hits the bottom of the viewport",
  3. the element your Root wraps around is only 100vh tall, so the animation's duration is 0.

To fix this, either add more height to the element your Root wraps, or tweak the end value to be something like bottom start, which would mean "when the bottom of the scroller hits the start of the viewport".


GSAP files are subject to GreenSock's standard license which can be found at https://greensock.com/standard-license/

Extension points exported contracts — how you extend this code

AnimationProps (Interface)
(no doc)
scrollytelling/src/types/index.ts
AppStore (Interface)
(no doc)
website/src/context/use-app-store.ts
PinProps (Interface)
(no doc)
scrollytelling/src/components/pin/index.tsx
ParallaxProps (Interface)
(no doc)
scrollytelling/src/components/parallax/index.tsx
RegisterGsapPluginsProps (Interface)
(no doc)
scrollytelling/src/components/register-plugins/index.tsx

Core symbols most depended-on inside this repo

toVw
called by 17
website/src/lib/utils.ts
clsx
called by 12
scrollytelling/src/util/index.ts
useScrollytelling
called by 4
scrollytelling/src/context/index.tsx
on
called by 4
scrollytelling/src/util/emmiter.ts
emit
called by 3
scrollytelling/src/util/emmiter.ts
loadImage
called by 2
scrollytelling/src/image-sequence-canvas.tsx
handleUpdate
called by 2
scrollytelling/src/components/debugger/visualizer/index.tsx
addTweenToTimeline
called by 2
scrollytelling/src/components/animation/index.tsx

Shape

Function 71
Interface 5
Method 5
Class 2

Languages

TypeScript100%

Modules by API surface

scrollytelling/src/components/debugger/visualizer/index.tsx10 symbols
scrollytelling/src/util/emmiter.ts7 symbols
website/src/app/sections/footer/index.tsx6 symbols
website/src/lib/utils.ts4 symbols
website/src/app/hooks/use-mouse-tracker.ts4 symbols
scrollytelling/src/util/index.ts4 symbols
scrollytelling/src/image-sequence-canvas.tsx4 symbols
website/src/app/sections/lab-cylinder/intro/index.tsx3 symbols
scrollytelling/src/components/stagger/index.tsx3 symbols
website/src/hooks/use-viewport.tsx2 symbols
website/src/hooks/use-media.ts2 symbols
website/src/app/sections/hero/mac-model.tsx2 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add scrollytelling \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact