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
Copy file name to clipboardExpand all lines: README.md
+13-16Lines changed: 13 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,6 @@ npm i react-scroll-parallax --save
24
24
The `<ParallaxProvider />` should wrap the component tree that contains all `<Parallax />` components. This should be a top level component like `<AppContainer />`. The `<ParallaxProvider />` will then provide necessary context to the [`parallaxController`](#parallax-controller-context) for all `<Parallax />` elements. For example:
@@ -39,24 +38,22 @@ class AppContainer extends Component {
39
38
40
39
```
41
40
42
-
Import the `Parallax` component...
41
+
Import the `Parallax` component and use it anywhere within the provider like so:
43
42
44
-
```javascript
43
+
```jsx
45
44
import { Parallax } from'react-scroll-parallax';
46
-
```
47
-
48
-
... then use it like so:
49
45
50
-
```jsx
51
-
<Parallax
52
-
className="custom-class"
53
-
offsetYMax={20}
54
-
offsetYMin={-20}
55
-
slowerScrollRate
56
-
tag="figure"
57
-
>
58
-
<img src="/image"/>
59
-
</Parallax>
46
+
constImage= () => (
47
+
<Parallax
48
+
className="custom-class"
49
+
offsetYMax={20}
50
+
offsetYMin={-20}
51
+
slowerScrollRate
52
+
tag="figure"
53
+
>
54
+
<img src="/image.jpg"/>
55
+
</Parallax>
56
+
);
60
57
```
61
58
62
59
**NOTE:** Scroll state and positions of elements on the page are cached for performance reasons. This means that if the page height changes (perhaps from images loading) after `<Parallax />` components are mounted the controller won't properly determine when the elements are in view. To correct this you can call the `parallaxController.update()` method from any child component of the `<ParallaxProvider />` via `context`. More details on how here: [Parallax Controller Context](#parallax-controller-context).
0 commit comments