Skip to content

Commit 779f774

Browse files
committed
update readme to clarify that the ParallaxController is a global on the window (#4)
1 parent fcee9fa commit 779f774

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ npm i react-scroll-parallax --save
2020

2121
## Usage
2222

23-
Import `ParallaxController` on the client side and call `ParallaxController.init()` to create the global `ParallaxController` which will handle updating all parallax elements on scroll.
23+
Import `ParallaxController` on the client side and call `ParallaxController.init()` to create the global `ParallaxController` on the `window` which will handle controlling all parallax elements on scroll. Ideally, this would be called at the root of your react app on the client.
2424

2525
```javascript
2626
import { ParallaxController } from 'react-scroll-parallax';
@@ -48,7 +48,7 @@ import { Parallax } from 'react-scroll-parallax';
4848
</Parallax>
4949
```
5050

51-
NOTE: `ParallaxController` caches the scroll state and positions of elements on the page for performance reasons. This means that if the page height changes (perhaps by images loading) after `<Parallax />` components are mounted it won't properly determine when the elements are in view. To correct this call the `update()` once every thing has loaded and ready.
51+
**NOTE:** `ParallaxController` caches the scroll state and positions of elements on the page for performance reasons. This means that if the page height changes (perhaps from images loading) after `<Parallax />` components are mounted it won't properly determine when the elements are in view. To correct this call the `update()` from the global `ParallaxController` once every thing has loaded and is ready.
5252

5353
## Parallax Component Props
5454

@@ -111,12 +111,14 @@ Optionally pass a tag name to be applied to the outer most parallax element. For
111111

112112
## Parallax Controller
113113

114-
The following are public methods available on the `ParallaxController` global:
115-
116114
**`init()`**
117115

118116
Initilize the `ParallaxController` on the client with the `init` static method.
119117

118+
**NOTE:** Calling `ParallaxController.init()` creates an instance of the controller on the `window` using the same name, e.g. `window.ParallaxController`.
119+
120+
The following are public methods available on the `window.ParallaxController` global:
121+
120122
**`update()`**
121123

122124
Updates all cached attributes for parallax elements then updates their positions.

0 commit comments

Comments
 (0)