You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React components to create parallax scroll effects for banners, images or any other DOM elements. Uses a single scroll listener via [Parallax Controller](https://github.com/jscottsmith/parallax-controller) to add vertical or horizontal scrolling based offsets to elements based on their position in the viewport. [Optimized](https://github.com/jscottsmith/parallax-controller#optimizations-to-reduce-jank) to _reduce_ jank on scroll and works with universal (server-side rendered) React apps.
5
+
React hooks and components to create parallax scroll effects for banners, images or any other DOM elements. Utilizes[Parallax Controller](https://github.com/jscottsmith/parallax-controller) to add vertical or horizontal scrolling based effects to elements. [Optimized](https://parallax-controller.vercel.app/docs/performance) to _reduce_ jank on scroll and works with SSR and SSG rendered React apps.
6
6
7
7
If you're coming from [V2](https://github.com/jscottsmith/react-scroll-parallax/tree/v2.4.2), here's a [migration guide](https://github.com/jscottsmith/react-scroll-parallax/blob/master/docs/migration-guide.md).
-[Optimizations to Reduce Jank](#optimizations-to-reduce-jank)
53
45
-[PSA](#psa)
54
46
@@ -70,12 +62,23 @@ function App() {
70
62
}
71
63
```
72
64
73
-
Then import the `Parallax` component and use it anywhere within the provider. Here's an example that will transform the element on the `translateY` axis starting at `-20%` and ending at `20%` (`translateY = [-20, 20]`\*percent is assumed with no provided unit).
65
+
Then import the `useParallax` hook and use it anywhere within the provider. Here's an example that uses the `speed` prop so simply speed up (or slowdown) the rate of scroll.
You can also use the `Parallax` component. Here's an example that will transform the element on the `translateY` axis starting at `-20%` and ending at `20%` (`translateY = [-20, 20]`\*percent is assumed with no provided unit).
74
77
75
78
```jsx
76
79
import { Parallax } from'react-scroll-parallax';
77
80
78
-
constVerticalParallax= () => (
81
+
constComponent= () => (
79
82
<Parallax translateY={[-20, 20]}>
80
83
<div className="my-thing"/>
81
84
</Parallax>
@@ -87,7 +90,7 @@ Example with transforms on the `translateX` axis starting at `-100px` and ending
87
90
```jsx
88
91
import { Parallax } from'react-scroll-parallax';
89
92
90
-
constHorizontalParallax= () => (
93
+
constComponent= () => (
91
94
<Parallax translateX={['-100px', '200px']}>
92
95
<div className="my-thing"/>
93
96
</Parallax>
@@ -107,16 +110,4 @@ If you're encountering issues like the parallax element jumping around or becomi
107
110
108
111
## Optimizations to Reduce Jank
109
112
110
-
Considerations have been taken to reduce jank -- [please read more here](https://github.com/jscottsmith/parallax-controller#optimizations-to-reduce-jank) on how this is done
111
-
112
-
### **PSA**
113
-
114
-
Even with optimizations _scroll effects can cause jank_. It's also important to keep in mind that scroll effects are usually not critical to a users experience and sometimes can be annoying.
115
-
116
-
If you use these components make sure you seriously consider the following:
117
-
118
-
- Keep images small (do not use inappropriately high resolutions) and optimized (use appropriate compression)
119
-
- Reduce the number of scroll effects on elements in view and on the page in total
120
-
- Disable the use — or limit the amount — of scroll effects for users on mobile devices
121
-
122
-
Follow the above and you should keep scrolling smooth and users happy.
113
+
Considerations have been taken to reduce jank -- [please read more here](https://parallax-controller.vercel.app/docs/performance) on how this is done
0 commit comments