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
Copy file name to clipboardExpand all lines: documentation/docs/usage/components/parallax-banner-component.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@ sidebar_position: 3
6
6
7
7
Component that sets up layers of `useParallax` elements to achieve a parallaxing banner. Enables the layering of images, or custom markup, with scroll effects in a container that hides overflow.
Copy file name to clipboardExpand all lines: documentation/docs/usage/components/parallax-provider.md
+28-6Lines changed: 28 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,15 @@ sidebar_position: 2
6
6
7
7
The `<ParallaxProvider />` component is meant to wrap a root level component in your application and is necessary to provide access through the React context API to the [Parallax Controller](https://parallax-controller.vercel.app/docs/intro).
This component should only be used once in your app, for instance in an `<AppContainer />` component that won't be mounted/unmounted during route changes. Like so:
@@ -28,7 +30,7 @@ You can have multiple providers, however they will all be independent instances
28
30
29
31
:::
30
32
31
-
## ParallaxProvider Props
33
+
## Props
32
34
33
35
The following props configure the `<ParallaxProvider>` component:
34
36
@@ -37,9 +39,29 @@ The following props configure the `<ParallaxProvider>` component:
37
39
|**scrollAxis**|`string`|`vertical`| Optionally pass the scroll axis for setting horizontal/vertical scrolling. One of `vertical` or `horizontal`|
38
40
|**scrollContainer**|`HTMLElement`|`<body>`| Optionally set the container that has overflow and will contain parallax elements. Defaults to the document scroll body. |
39
41
40
-
## Example: Scroll Container
42
+
## More Examples
43
+
44
+
Using props you can configure the provider for the following conditions.
45
+
46
+
### Horizontal Scrolling
47
+
48
+
If your app's overflow is horizontal, you'll need to change the `scrollAxis`:
49
+
50
+
```tsx
51
+
const AppContainer = () => (
52
+
<ParallaxProviderscrollAxis="horizontal">
53
+
<Router>
54
+
<App />
55
+
</Router>
56
+
</ParallaxProvider>
57
+
);
58
+
```
59
+
60
+
### Scroll Container
61
+
62
+
By default the `<ParallaxProvider>` uses the document scrolling element. If your app's overflow is a unique element you need to provide the element as the `scrollContainer`.
41
63
42
-
By default the `<ParallaxProvider>` uses the document scrolling element. If your app's overflow is a unique element you need to provide the element as the `scrollContainer`. Here's how:
64
+
Here's how you can do that using React hooks to set a `ref` to a DOM element. The `useEffect` will be called once after mounting then update state with the element to be passed to the provider.
Copy file name to clipboardExpand all lines: documentation/docs/usage/hooks/use-parallax-controller.md
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,19 @@
2
2
3
3
This hook provides you access to the [`ParallaxController`](https://parallax-controller.vercel.app/docs/api/parallax-controller/) via [React context](https://facebook.github.io/react/docs/context.html). The hook must be called in a component rendered within the [`<ParallaxProvider>`](/docs/usage/components/parallax-provider). The most common usage of the controller is to update cache if the page layout has changed.
Copy file name to clipboardExpand all lines: documentation/docs/usage/hooks/use-parallax.md
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,15 @@
2
2
3
3
Main hook for applying parallax effects to a DOM element. Any of the documented [effects and configurations](https://parallax-controller.vercel.app/docs/usage/props) can be passed as params to the hook.
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