Skip to content

Commit f1f56be

Browse files
committed
docs: update readme
1 parent c41ad13 commit f1f56be

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

README.md

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![npm version](https://badge.fury.io/js/react-scroll-parallax.svg)](https://badge.fury.io/js/react-scroll-parallax) [![Build Status](https://travis-ci.org/jscottsmith/react-scroll-parallax.svg?branch=master)](https://travis-ci.org/jscottsmith/react-scroll-parallax) [![codecov](https://codecov.io/gh/jscottsmith/react-scroll-parallax/branch/master/graph/badge.svg)](https://codecov.io/gh/jscottsmith/react-scroll-parallax)
44

5-
React components to create parallax scroll effects for banners, images or any other DOM elements. Uses a single scroll listener via [Parallax Controller](https://github.com/jscottsmith/parallax-controller) to add vertical or horizontal scrolling based offsets to elements based on their position in the viewport. [Optimized](https://github.com/jscottsmith/parallax-controller#optimizations-to-reduce-jank) to _reduce_ jank on scroll and works with universal (server-side rendered) React apps.
5+
React hooks and components to create parallax scroll effects for banners, images or any other DOM elements. Utilizes[Parallax Controller](https://github.com/jscottsmith/parallax-controller) to add vertical or horizontal scrolling based effects to elements. [Optimized](https://parallax-controller.vercel.app/docs/performance) to _reduce_ jank on scroll and works with SSR and SSG rendered React apps.
66

77
If you're coming from [V2](https://github.com/jscottsmith/react-scroll-parallax/tree/v2.4.2), here's a [migration guide](https://github.com/jscottsmith/react-scroll-parallax/blob/master/docs/migration-guide.md).
88

@@ -39,16 +39,8 @@ yarn add react-scroll-parallax
3939

4040
- [Example Usage](#usage)
4141
- [`<Parallax>`](/docs/parallax-component.md)
42-
- [Parallax Props](/docs/parallax-component.md#props)
4342
- [`<ParallaxBanner>`](/docs/parallax-banner-component.md)
44-
- [Banner Usage](/docs/parallax-banner-component.md#banner-usage)
45-
- [Banner Props](/docs/parallax-banner-component.md#banner-props)
46-
- [Banner Layers Prop](/docs/parallax-banner-component.md#banner-layers-prop)
4743
- [`<ParallaxProvider>`](/docs/parallax-provider-component.md)
48-
- [ParallaxProvider Props](/docs/parallax-provider-component.md#parallaxprovider-props)
49-
- [Parallax Controller Context](/docs/parallax-controller-context.md)
50-
- [Available Methods](/docs/parallax-controller-context.md#available-methods)
51-
- [Browser Support](#browser-support)
5244
- [Optimizations to Reduce Jank](#optimizations-to-reduce-jank)
5345
- [PSA](#psa)
5446

@@ -70,12 +62,23 @@ function App() {
7062
}
7163
```
7264

73-
Then import the `Parallax` component and use it anywhere within the provider. Here's an example that will transform the element on the `translateY` axis starting at `-20%` and ending at `20%` (`translateY = [-20, 20]` \*percent is assumed with no provided unit).
65+
Then import the `useParallax` hook and use it anywhere within the provider. Here's an example that uses the `speed` prop so simply speed up (or slowdown) the rate of scroll.
66+
67+
```jsx
68+
import { useParallax } from 'react-scroll-parallax';
69+
70+
const Component = () => {
71+
const { ref } = useParallax({ speed: 10 });
72+
return <div ref={ref} className="my-thing" />;
73+
};
74+
```
75+
76+
You can also use the `Parallax` component. Here's an example that will transform the element on the `translateY` axis starting at `-20%` and ending at `20%` (`translateY = [-20, 20]` \*percent is assumed with no provided unit).
7477

7578
```jsx
7679
import { Parallax } from 'react-scroll-parallax';
7780

78-
const VerticalParallax = () => (
81+
const Component = () => (
7982
<Parallax translateY={[-20, 20]}>
8083
<div className="my-thing" />
8184
</Parallax>
@@ -87,7 +90,7 @@ Example with transforms on the `translateX` axis starting at `-100px` and ending
8790
```jsx
8891
import { Parallax } from 'react-scroll-parallax';
8992

90-
const HorizontalParallax = () => (
93+
const Component = () => (
9194
<Parallax translateX={['-100px', '200px']}>
9295
<div className="my-thing" />
9396
</Parallax>
@@ -107,16 +110,4 @@ If you're encountering issues like the parallax element jumping around or becomi
107110

108111
## Optimizations to Reduce Jank
109112

110-
Considerations have been taken to reduce jank -- [please read more here](https://github.com/jscottsmith/parallax-controller#optimizations-to-reduce-jank) on how this is done
111-
112-
### **PSA**
113-
114-
Even with optimizations _scroll effects can cause jank_. It's also important to keep in mind that scroll effects are usually not critical to a users experience and sometimes can be annoying.
115-
116-
If you use these components make sure you seriously consider the following:
117-
118-
- Keep images small (do not use inappropriately high resolutions) and optimized (use appropriate compression)
119-
- Reduce the number of scroll effects on elements in view and on the page in total
120-
- Disable the use — or limit the amount — of scroll effects for users on mobile devices
121-
122-
Follow the above and you should keep scrolling smooth and users happy.
113+
Considerations have been taken to reduce jank -- [please read more here](https://parallax-controller.vercel.app/docs/performance) on how this is done

0 commit comments

Comments
 (0)