Fireship · @fireship
The Parallax Effect // 5 Minute WebDev Project
Uploaded April 13, 2022 · Length 5:01
Summary
Learn how to implement the parallax effect on a website using React Spring and create a unique animated webpage.
- parallax effect
- react spring
- web development
- animation
- javascript
- reactjs
- web design
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
the parallax effect it's one of the
- 0:01
oldest and coolest tricks in the design
- 0:03
playbook it works by making different
- 0:05
layers of content or backgrounds move at
- 0:08
different speeds when the web page is
- 0:09
scrolled creating the optical illusion
- 0:11
of three-dimensional depth it's used
- 0:13
extensively on apple product pages like
- 0:15
the new iphone landing page and can be
- 0:17
used in subtle ways like the firewatch
- 0:19
game where it feels like you're
- 0:20
descending behind a mountain before
- 0:22
reaching the main content or one of the
- 0:23
most mind-blowing examples is the boat
- 0:26
which contains six chapters of non-stop
- 0:28
parallax looks awesome so how do i
- 0:30
implement it on my website over the next
- 0:32
few minutes you will build this homepage
- 0:34
of a cat parachuting from the moon down
- 0:36
to the ground using an awesome library
- 0:38
called react spring along the way you'll
- 0:40
learn how to quickly transform a boring
- 0:42
layout into something amazing at the end
- 0:44
of the video we will also look at some
- 0:46
more advanced possibilities and
- 0:48
drawbacks of the parallax technique if
- 0:50
you're new here like and subscribe and
- 0:52
upgrade to fireship pro to get more
- 0:53
tutorials like this let's first make
- 0:55
sure we understand how the parallax
- 0:57
effect works we have a background image
- 0:59
two images actually of the moon and a
- 1:01
landscape but we also have text and
- 1:03
images in the foreground that scroll at
- 1:05
different speeds on top of that you'll
- 1:07
notice that the text animates in with a
- 1:09
springy animation the cat starts at the
- 1:11
bottom and then very slowly scrolls up
- 1:13
to the top this simulates how
- 1:14
perspective can change the relative
- 1:16
speed of objects as the viewpoint moves
- 1:18
making the website feel much more alive
- 1:20
to get started create a react app with
- 1:22
your favorite tool i'm using beat from
- 1:24
there install the react spring parallax
- 1:26
package if you're not familiar react
- 1:28
spring is an awesome tool that can
- 1:29
easily add life to your components with
- 1:31
spring animations which itself is a
- 1:33
technique that relies on physics instead
- 1:35
of durations and curves for defining
- 1:37
animations the library provides two
- 1:39
components the first of which is
- 1:41
parallax you can think of a parallax
- 1:43
scene as multiple pages that gives us a
- 1:45
context to start animating to animate
- 1:47
the children we use the parallax layer
- 1:49
component by default you can think of
- 1:51
each layer as a page that will take up
- 1:53
the entire screen to see it in action
- 1:55
let's go ahead and add two different
- 1:57
layers you can add whatever ui you want
- 1:59
inside of them using the default


