Skip to content

Commit 5a974af

Browse files
committed
feat: return a single element from <Parallax>, remove unused inner element props
1 parent 249c936 commit 5a974af

File tree

4 files changed

+12
-48
lines changed

4 files changed

+12
-48
lines changed

docs/migration-guide.md

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

33
With mostly just new features, V3 also makes a few breaking changes. See the following and migrate any code that is affected.
44

5-
### Renamed Props
5+
### Renamed Props for \<Parallax\>
66

7-
If you've used any of the following props simply rename to the new ones.
7+
If you've used any of the following props simply rename to new ones or refactor if if they are no longer supported.
88

99
1. `styleOuter` becomes `style`.
10-
2. `styleInner` becomes `innerStyle`.
11-
3. `tagOuter` becomes `tag`.
12-
4. `tagInner` becomes `innerTag`.
13-
5. `x` becomes `translateX`.
14-
6. `y` becomes `translateY`.
10+
2. `tagOuter` becomes `tag`.
11+
3. `x` becomes `translateX`.
12+
4. `y` becomes `translateY`.
13+
5. `styleInner` is no longer supported - There's only a single element returned by the component.
14+
6. `tagInner` is no longer supported - There's only a single element returned by the component.
1515

1616
### Using the context hook.
1717

@@ -31,11 +31,7 @@ const parallaxController = useController();
3131

3232
### Removed default class names
3333

34-
If you relied on either the `parallax-outer` or `parallax-inner` class names for styling you will need to explicitly define them.
35-
36-
```jsx
37-
<Parallax className="parallax-outer" innerClassName="parallax-inner" />
38-
```
34+
If you relied on either the `parallax-outer` or `parallax-inner` class names for styling you will need to refactor or set them manually.
3935

4036
# V1 Migration Guide
4137

docs/parallax-component.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@ The following are all props that can be passed to the `<Parallax>` component:
5858
| **rootMargin** | `object` | | Margin to be applied as the bounds around an element. This will affect when an element is determined to be considered in the viewport. Example: `{ top: 100, right: 100, bottom: 100, left: 100 }` |
5959
| **disabled** | `boolean` | `false` | Disables parallax effects on individual elements when `true`. |
6060
| **className** | `string` | | Class names to be added to the outermost parallax element. |
61-
| **innerClassName** | `string` | | Class names to be added to the outermost parallax element. |
6261
| **style** | `object` | | Style object to be added to the outermost parallax element. |
63-
| **innerStyle** | `object` | | Style object to be added to the innermost parallax element. |
6462
| **tag** | `string` | `div` | HTML element tag name to be applied to the outermost parallax element. |
65-
| **innerTag** | `string` | `div` | HTML element tag name to be applied to the innermost parallax element. |
6663
| **shouldStartAnimationInitialInView** | `boolean` | `false` | Will start the animation at initial element position if the element is positioned inside the view when scroll is at zero. |
6764
| **startScroll** | `number` | | Scroll top value to begin the animation. When provided along with `endScroll` relative scroll values will be ignored. |
6865
| **endScroll** | `number` | | Scroll top value to end the animation. When provided along with `startScroll` relative scroll values will be ignored. |

src/components/Parallax/index.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,16 @@ import { useParallax } from '../../hooks/useParallax';
33
import { ParallaxProps } from '../../types';
44

55
export function Parallax(props: PropsWithChildren<ParallaxProps>) {
6-
const Outer = props.tag;
7-
const Inner = props.innerTag;
6+
const Tag = props.tag;
87
const { ref } = useParallax(props);
98
return (
10-
<Outer className={props.className} style={props.style}>
11-
<Inner
12-
className={props.innerClassName}
13-
ref={ref}
14-
style={props.innerStyle}
15-
>
16-
{props.children}
17-
</Inner>
18-
</Outer>
9+
<Tag className={props.className} style={props.style} ref={ref}>
10+
{props.children}
11+
</Tag>
1912
);
2013
}
2114

22-
export const Component = () => {
23-
const { ref } = useParallax<HTMLDivElement>({ translateY: [100, -100] });
24-
return (
25-
<div ref={ref}>
26-
<div />
27-
</div>
28-
);
29-
};
30-
3115
Parallax.defaultProps = {
3216
disabled: false,
33-
innerTag: 'div',
3417
tag: 'div',
3518
};

src/types.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,10 @@ export interface ParallaxProps extends ParallaxElementConfig {
1414
* Class names to be added to the outermost parallax element.
1515
*/
1616
className?: string;
17-
/**
18-
* Class names to be added to the outermost parallax element.
19-
*/
20-
innerClassName?: string;
21-
/**
22-
* Style object to be added to the innermost parallax element.
23-
*/
24-
innerStyle?: any;
2517
/**
2618
* Style object to be added to the outermost parallax element.
2719
*/
2820
style?: any;
29-
/**
30-
* HTML element tag name to be applied to the innermost parallax element.
31-
*/
32-
innerTag?: any;
3321
/**
3422
* HTML element tag name to be applied to the outermost parallax element.
3523
*/

0 commit comments

Comments
 (0)