From 779f774c7e3850d47f001ccb8bb45e0a0d3ae617 Mon Sep 17 00:00:00 2001 From: J Scott Smith Date: Mon, 14 Aug 2017 00:16:21 -0700 Subject: [PATCH] update readme to clarify that the `ParallaxController` is a global on the window (#4) --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eb96991d1..b47965cb2 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ npm i react-scroll-parallax --save ## Usage -Import `ParallaxController` on the client side and call `ParallaxController.init()` to create the global `ParallaxController` which will handle updating all parallax elements on scroll. +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. ```javascript import { ParallaxController } from 'react-scroll-parallax'; @@ -48,7 +48,7 @@ import { Parallax } from 'react-scroll-parallax'; ``` -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 `` 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. +**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 `` 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. ## Parallax Component Props @@ -111,12 +111,14 @@ Optionally pass a tag name to be applied to the outer most parallax element. For ## Parallax Controller -The following are public methods available on the `ParallaxController` global: - **`init()`** Initilize the `ParallaxController` on the client with the `init` static method. +**NOTE:** Calling `ParallaxController.init()` creates an instance of the controller on the `window` using the same name, e.g. `window.ParallaxController`. + +The following are public methods available on the `window.ParallaxController` global: + **`update()`** Updates all cached attributes for parallax elements then updates their positions.