Skip to content

Commit c3763f9

Browse files
committed
more usage updates in readme
1 parent 3b6a4f9 commit c3763f9

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ npm i react-scroll-parallax --save
2424
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:
2525

2626
```jsx
27-
...
2827
import { ParallaxProvider } from 'react-scroll-parallax';
2928

3029
class AppContainer extends Component {
@@ -39,24 +38,22 @@ class AppContainer extends Component {
3938

4039
```
4140

42-
Import the `Parallax` component...
41+
Import the `Parallax` component and use it anywhere within the provider like so:
4342

44-
```javascript
43+
```jsx
4544
import { Parallax } from 'react-scroll-parallax';
46-
```
47-
48-
... then use it like so:
4945

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+
const Image = () => (
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+
);
6057
```
6158

6259
**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

Comments
 (0)