Skip to content

Commit a3da5d2

Browse files
committed
docs: example independent easing
1 parent 3b7cb38 commit a3da5d2

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

documentation/docs/examples/easing.mdx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
15
import { EasingDemo } from '/src/components/easing-demo';
26

3-
# Easing
7+
# Easing Animation
48

59
You can provide [easing presets](https://parallax-controller.v1.damnthat.tv/docs/usage/props#cubic-bezier-easing-function) or [cubic-bezier curve params](https://parallax-controller.v1.damnthat.tv/docs/usage/props#cubic-bezier-easing-function) to the `useParallax` hook or `<Parallax />` component.
610

@@ -20,9 +24,9 @@ function Component() {
2024

2125
**Note:** When defining an `easing` prop like above, ALL provided CSS effects will be eased.
2226

23-
<EasingDemo easing="easeOutQuad" />
27+
<EasingDemo eased={{ easing: 'easeOutQuad' }} />
2428

25-
# Custom cubic-bezier
29+
## Custom cubic-bezier
2630

2731
Define a custom cubic-bezier curve by providing the 4 params to the `easing` prop.
2832

@@ -36,4 +40,29 @@ function Component() {
3640
}
3741
```
3842

39-
<EasingDemo easing={[1, -0.75, 0.5, 1.34]} />
43+
<EasingDemo eased={{ easing: [1, -0.75, 0.5, 1.34] }} />
44+
45+
## Independent Easing
46+
47+
Each effect can define it's own easing by passing a third param to the effect.
48+
49+
```tsx
50+
function Component() {
51+
const parallax = useParallax<HTMLDivElement>({
52+
translateX: [0, 100, 'easeOutQuint'],
53+
translateY: [-100, 100, 'easeInQuint'],
54+
});
55+
return <div ref={parallax.ref} />;
56+
}
57+
```
58+
59+
<EasingDemo
60+
default={{
61+
translateX: [0, 100],
62+
translateY: [-100, 100],
63+
}}
64+
eased={{
65+
translateX: [0, 100, 'easeOutQuint'],
66+
translateY: [-100, 100, 'easeInQuint'],
67+
}}
68+
/>

documentation/docs/examples/how-it-works.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
15
import { ElementProgress } from '/src/components/element-progress';
26
import { HowItWorks } from '/src/components/how-it-works';
37
import { BeyondCSSEffects } from '/src/components/beyond-css-effects';

documentation/src/components/easing-demo/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import { EasingParam } from 'parallax-controller';
21
import React from 'react';
32
import { useParallax } from 'react-scroll-parallax';
3+
import { ParallaxProps } from 'react-scroll-parallax/dist/types';
44
import { BgContainer } from '../bg-container';
55

6-
export const EasingDemo = (props: { easing: EasingParam }) => {
6+
export const EasingDemo = (props: {
7+
eased: ParallaxProps;
8+
default: ParallaxProps;
9+
}) => {
710
const parallaxLinear = useParallax<HTMLDivElement>({
811
translateX: [0, 100],
912
shouldAlwaysCompleteAnimation: true,
13+
...props.default,
1014
});
1115

1216
const parallaxEased = useParallax<HTMLDivElement>({
1317
translateX: [0, 100],
1418
shouldAlwaysCompleteAnimation: true,
15-
easing: props.easing,
19+
...props.eased,
1620
});
1721

1822
return (

0 commit comments

Comments
 (0)