• Stars
    star
    1,117
  • Rank 41,576 (Top 0.9 %)
  • Language
    TypeScript
  • License
    Other
  • Created over 1 year ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library for creating Scrollytelling animations, powered by React & GSAP.

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. While preparing his talk for the React Miami Conference, JB 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

For our talk at React Miami Conf, 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


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

More Repositories

1

basement-grotesque

The basement grotesque typeface.
TypeScript
301
star
2

commerce-toolkit

Ship better storefronts 🛍
TypeScript
279
star
3

basement-laboratory

We combine intensive technology with design expertise.
JavaScript
230
star
4

next-typescript

We make cool shit that performs, and we start with this template.
TypeScript
170
star
5

next-real-viewport

No more horizontal scroll when using 100vw 🎉. No more issues with the 100vh in mobile browsers 🤯.
TypeScript
119
star
6

next-shopify-ts

A boilerplate for using Next.js with Shopify, TypeScript, and react-query 🔥
TypeScript
33
star
7

next-shopify

A context, a hook, and an API route handler, to manage a Shopify Storefront in your Next.js app.
TypeScript
30
star
8

blender-bezier-exporter

Python
23
star
9

gists

to store snippets of code (because you can't create gists as an org 🤷)
JavaScript
21
star
10

workshop-nextjs-pizza

TypeScript
21
star
11

bsmnt-links

A free URL shortener to deploy with your own domain.
TypeScript
10
star
12

creative-dev-challenge

A challenge for devs aiming to join basement as Creative Developer
TypeScript
10
star
13

next-contentful-graphql

Setup for using next with Contentful's Graphql API and have code generation for the schema and the queries and stuff... with great typescript support.
CSS
8
star
14

create-bsmnt-app

TypeScript
7
star
15

app-dir-example

App dir example made with our next-typescript starter.
CSS
7
star
16

react-shopify-drop

A react library to interact with Shopify's Storefront API
TypeScript
6
star
17

challenge

First step in order to become a basementer, lol.
3
star
18

b-hydra

CSS
3
star
19

scripts

Python
3
star
20

creative-toolkit

TypeScript
3
star
21

lbac-website

TypeScript
2
star
22

livepeer-org

JavaScript
1
star
23

next-shopify-drop

TypeScript
1
star