Fireship · @fireship

The Parallax Effect // 5 Minute WebDev Project

Uploaded April 13, 2022 · Length 5:01

The Parallax Effect // 5 Minute WebDev Project

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.

  1. 0:00

    the parallax effect it's one of the

  2. 0:01

    oldest and coolest tricks in the design

  3. 0:03

    playbook it works by making different

  4. 0:05

    layers of content or backgrounds move at

  5. 0:08

    different speeds when the web page is

  6. 0:09

    scrolled creating the optical illusion

  7. 0:11

    of three-dimensional depth it's used

  8. 0:13

    extensively on apple product pages like

  9. 0:15

    the new iphone landing page and can be

  10. 0:17

    used in subtle ways like the firewatch

  11. 0:19

    game where it feels like you're

  12. 0:20

    descending behind a mountain before

  13. 0:22

    reaching the main content or one of the

  14. 0:23

    most mind-blowing examples is the boat

  15. 0:26

    which contains six chapters of non-stop

  16. 0:28

    parallax looks awesome so how do i

  17. 0:30

    implement it on my website over the next

  18. 0:32

    few minutes you will build this homepage

  19. 0:34

    of a cat parachuting from the moon down

  20. 0:36

    to the ground using an awesome library

  21. 0:38

    called react spring along the way you'll

  22. 0:40

    learn how to quickly transform a boring

  23. 0:42

    layout into something amazing at the end

  24. 0:44

    of the video we will also look at some

  25. 0:46

    more advanced possibilities and

  26. 0:48

    drawbacks of the parallax technique if

  27. 0:50

    you're new here like and subscribe and

  28. 0:52

    upgrade to fireship pro to get more

  29. 0:53

    tutorials like this let's first make

  30. 0:55

    sure we understand how the parallax

  31. 0:57

    effect works we have a background image

  32. 0:59

    two images actually of the moon and a

  33. 1:01

    landscape but we also have text and

  34. 1:03

    images in the foreground that scroll at

  35. 1:05

    different speeds on top of that you'll

  36. 1:07

    notice that the text animates in with a

  37. 1:09

    springy animation the cat starts at the

  38. 1:11

    bottom and then very slowly scrolls up

  39. 1:13

    to the top this simulates how

  40. 1:14

    perspective can change the relative

  41. 1:16

    speed of objects as the viewpoint moves

  42. 1:18

    making the website feel much more alive

  43. 1:20

    to get started create a react app with

  44. 1:22

    your favorite tool i'm using beat from

  45. 1:24

    there install the react spring parallax

  46. 1:26

    package if you're not familiar react

  47. 1:28

    spring is an awesome tool that can

  48. 1:29

    easily add life to your components with

  49. 1:31

    spring animations which itself is a

  50. 1:33

    technique that relies on physics instead

  51. 1:35

    of durations and curves for defining

  52. 1:37

    animations the library provides two

  53. 1:39

    components the first of which is

  54. 1:41

    parallax you can think of a parallax

  55. 1:43

    scene as multiple pages that gives us a

  56. 1:45

    context to start animating to animate

  57. 1:47

    the children we use the parallax layer

  58. 1:49

    component by default you can think of

  59. 1:51

    each layer as a page that will take up

  60. 1:53

    the entire screen to see it in action

  61. 1:55

    let's go ahead and add two different

  62. 1:57

    layers you can add whatever ui you want

  63. 1:59

    inside of them using the default