Skip to content

Commit 4a13438

Browse files
committed
docs: start scroll effects example doc
1 parent 8c76255 commit 4a13438

File tree

7 files changed

+150
-4
lines changed

7 files changed

+150
-4
lines changed

documentation/docs/examples/advanced-banners.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
hide_title: true
33
title: Advanced Banners
4-
sidebar_position: 3
4+
sidebar_position: 4
55
---
66

77
import { AdvancedBannerTop } from '/src/components/advanced-banner-top';

documentation/docs/examples/banners.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 2
2+
sidebar_position: 3
33
---
44

55
import { ParallaxBannerImages } from '/src/components/parallax-banner-images';

documentation/docs/examples/easing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 5
33
---
44

55
import { EasingDemo } from '/src/components/easing-demo';
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
import { ExampleRotation } from '/src/components/example-rotation';
6+
import { RotationAxis } from '/src/components/rotation-axis';
7+
8+
# Scroll Effects
9+
10+
More than just translate effects are possible. Here's some examples of the various effects possible.
11+
12+
## Rotation
13+
14+
You can spin an element around it's axis using the [rotate props](/docs/usage/parallax-props#available-css-effects).
15+
16+
### Around the default axis (z-axis)
17+
18+
Use the `rotate` prop to rotate an element around the z-axis. You can pass the `start` and `end` values as `deg` or `turns`. Numbers default to `deg`.
19+
20+
```tsx
21+
const Component = () => {
22+
const parallax = useParallax<HTMLDivElement>({
23+
rotate: [0, 360],
24+
});
25+
return (
26+
<div ref={parallax.ref} className="spinner">
27+
😵‍💫
28+
<div className="diamond">💎</div>
29+
<div className="clown">🤡</div>
30+
<div className="money">💰</div>
31+
<div className="hand">👌🏻</div>
32+
</div>
33+
);
34+
};
35+
```
36+
37+
<ExampleRotation />
38+
39+
### Around the y-axis
40+
41+
Rotations can be applied to any axis, `x`, `y`, or `z`. Here's an example of a rotation around the `y-axis` for perspective:
42+
43+
```tsx
44+
const Component = () => {
45+
const parallax = useParallax<HTMLDivElement>({
46+
rotateY: [0, 360],
47+
});
48+
return (
49+
<div ref={parallax.ref} className="spinner">
50+
<div className="thumbsup">👍🏻</div>
51+
<div className="clap">👏🏻</div>
52+
<div className="handsup">🙌🏻</div>
53+
<div className="thumbsdown">👎🏻</div>
54+
</div>
55+
);
56+
};
57+
```
58+
59+
<RotationAxis />

documentation/src/components/bg-container/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ export const BgContainer = (props: PropsWithChildren<{}>) => {
55
return (
66
<div className="relative my-2xl bg-gray-900 px-lg py-96 w-full rounded-md px-bg text-black overflow-hidden">
77
{/* <div className="h-screen" /> */}
8-
<div className="flex flex-row items-center justify-evenly w-full">
8+
9+
<div
10+
className="flex flex-row items-center justify-evenly w-full"
11+
style={{ perspective: '250px' }}
12+
>
913
{props.children}
1014
</div>
1115
{/* <div className="h-screen" /> */}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from 'react';
2+
import cx from 'classnames';
3+
import { useParallax } from 'react-scroll-parallax';
4+
import { BgContainer } from '../bg-container';
5+
6+
const shared =
7+
'absolute bg-blue-100 border-2 border-blue-500 border-solid rounded-lg h-14 w-14 flex items-center justify-center';
8+
9+
export const ExampleRotation = () => {
10+
const parallax = useParallax<HTMLDivElement>({
11+
rotate: [0, 360],
12+
shouldAlwaysCompleteAnimation: true,
13+
});
14+
return (
15+
<BgContainer>
16+
<div
17+
ref={parallax.ref}
18+
className="relative border-4 border-red-200 border-solid h-48 md:h-96 w-48 md:w-96 rounded-full flex items-center justify-center text-4xl"
19+
>
20+
😵‍💫
21+
<div
22+
className={cx(
23+
shared,
24+
'top-0 left-1/2 -translate-y-1/2 -translate-x-1/2'
25+
)}
26+
>
27+
💎
28+
</div>
29+
<div
30+
className={cx(
31+
shared,
32+
'right-0 top-1/2 -translate-y-1/2 translate-x-1/2'
33+
)}
34+
>
35+
🤡
36+
</div>
37+
<div
38+
className={cx(
39+
shared,
40+
'bottom-0 left-1/2 translate-y-1/2 -translate-x-1/2'
41+
)}
42+
>
43+
💰
44+
</div>
45+
<div
46+
className={cx(
47+
shared,
48+
'top-1/2 left-0 -translate-y-1/2 -translate-x-1/2'
49+
)}
50+
>
51+
👌🏻
52+
</div>
53+
</div>
54+
</BgContainer>
55+
);
56+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import cx from 'classnames';
3+
import { useParallax } from 'react-scroll-parallax';
4+
import { BgContainer } from '../bg-container';
5+
6+
const shared =
7+
'bg-blue-100 border-2 border-blue-500 border-solid rounded-lg h-14 w-14 flex items-center justify-center';
8+
9+
export const RotationAxis = () => {
10+
const parallax = useParallax<HTMLDivElement>({
11+
rotateY: [0, 360],
12+
shouldAlwaysCompleteAnimation: true,
13+
});
14+
return (
15+
<BgContainer>
16+
<div
17+
ref={parallax.ref}
18+
className="flex items-center gap-sm md:gap-lg justify-center text-4xl"
19+
>
20+
<div className={cx(shared)}>👍🏻</div>
21+
<div className={cx(shared)}>👏🏻</div>
22+
<div className={cx(shared)}>🙌🏻</div>
23+
<div className={cx(shared)}>👎🏻</div>
24+
</div>
25+
</BgContainer>
26+
);
27+
};

0 commit comments

Comments
 (0)