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
-[Optimizations to Reduce Jank](#optimizations-to-reduce-jank)
45
-
-[PSA](#psa)
48
+
49
+
### Docs: Hooks
50
+
51
+
-[`useParallax()`](/docs/use-parallax-hook.md)
52
+
-[`useController()`](/#todo)
53
+
-[`useParallaxImage`](/#todo)
46
54
47
55
## Usage
48
56
49
-
### Wrap with a ParallaxProvider
57
+
### First: Wrap with a ParallaxProvider
50
58
51
59
The [`<ParallaxProvider>`](#parallaxprovider) must wrap the component tree that contains all `<Parallax>` components. This should be a top level component like `<App>`. For example:
52
60
@@ -64,7 +72,7 @@ function App() {
64
72
}
65
73
```
66
74
67
-
### Create effects with useParallax()
75
+
### Then: Create effects with useParallax()
68
76
69
77
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.
70
78
@@ -77,7 +85,7 @@ const Component = () => {
77
85
};
78
86
```
79
87
80
-
### Create effects with \<Parallax>
88
+
### Or: Create effects with \<Parallax>
81
89
82
90
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).
To use the hook assign the `ref` returned to the element that you would like to apply effects to. Then provide the hook with the [prop configuration](https://parallax-controller.vercel.app/docs/usage/props) for the effects you need.
0 commit comments