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
Provides a React component and single passive scroll listener to add **vertical** scrolling based offsets to elements based on their position in the viewport. Works with universal (server-side rendered) React apps.
5
+
Provides React components to create parallax scroll effects for banners, images or any other DOM elements. Uses a single scroll listener to add **vertical** scrolling based offsets to elements based on their position in the viewport. [Optimized](#optimizations-to-reduce-jank) to _reduce_ jank on scroll and works with universal (server-side rendered) React apps.
*[Optimizations to Reduce Jank](#optimizations-to-reduce-jank)
45
+
*[PSA](#psa)
46
+
31
47
## Usage
32
48
33
49
The [`<ParallaxProvider>`](#parallaxprovider) should wrap the component tree that contains all `<Parallax>` components. This should be a top level component like `<AppContainer>`. For example:
@@ -68,9 +84,9 @@ const ParallaxImage = () => (
68
84
69
85
## \<Parallax>
70
86
71
-
The main component for manipulating an element's position based on scroll position within the viewport.
87
+
The main component for manipulating a DOM element's position based on it's position within the viewport.
72
88
73
-
### Props
89
+
### Parallax Props
74
90
75
91
The following are all props that can be passed to the `<Parallax>` component:
76
92
@@ -89,11 +105,11 @@ The following are all props that can be passed to the `<Parallax>` component:
89
105
90
106
## \<ParallaxBanner>
91
107
92
-
Component that utilizes `<Parallax>` components to achieve a parallaxing banner effect.
108
+
Component that utilizes `<Parallax>` components to achieve a parallaxing banner effect. Allows a single or multiple images to be parallaxed at different rates within the banner area.
93
109
94
-
### Example Usage
110
+
### Banner Usage
95
111
96
-
Use the `layers` prop to indicate all images, offset amounts and scroll rates. Optionally pass additional children to be rendered. Styles of the outermost banner element can also be changed. Here's an example:
112
+
Use the `layers` prop to indicate all images, offset amounts, and scroll rates. Optionally pass additional children to be rendered. Styles of the outermost banner element can also be changed. Here's an example:
97
113
98
114
```jsx
99
115
<ParallaxBanner
@@ -118,20 +134,20 @@ Use the `layers` prop to indicate all images, offset amounts and scroll rates. O
118
134
</ParallaxBanner>
119
135
```
120
136
121
-
### Props
137
+
### Banner Props
122
138
123
139
The following are all props that can be passed to the `<ParallaxBanner>` component:
@@ -222,6 +238,6 @@ React scroll parallax should support the last two versions of all major browsers
222
238
223
239
React Scroll Parallax uses a single [passive scroll listener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Improving_scrolling_performance_with_passive_listeners) (dependent on browser support) with the minimal amount of work done on the scroll event to prevent [jank](http://jankfree.org/) (calculations that cause layout, reflow and paint are cached initially and only updated when layout changes). Request animation frame is then used to decouple the scroll handler and further reduce jank. All offsets are applied with 3D transforms to utilize the GPU and prevent paints. If you have ideas to further optimize scrolling please PR or post an issue.
224
240
225
-
**PSA**
241
+
### **PSA**
226
242
227
-
It's 2017 and you probably shouldn't be building parallax sites—but if you do (like I did) and you use this package try and use it responsibly. Keeping images small and optimized, reducing the number of moving elements in view and on the page, and disabling scroll effects on mobile devicesshould keep scrolling smooth.
243
+
Even with these optimizations scroll effects can cause jank. If you use this lib make sure to keep images small and optimized, reduce the number of moving elements in view and on the page in total, and disable scroll effects on mobile devices. That should keep scrolling smooth and users happy.
0 commit comments