Skip to content

Commit 4403770

Browse files
committed
add scale transforms
1 parent 4a10f6a commit 4403770

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

docs/parallax-component.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ The following are all props that can be passed to the `<Parallax>` component:
5757
| **rotateX** | `string[]` or `number[]` | | Start and end rotation on x-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed. |
5858
| **rotateY** | `string[]` or `number[]` | | Start and end rotation on y-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed. |
5959
| **rotateZ** | `string[]` or `number[]` | | Start and end rotation on z-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed. |
60+
| **scale** | `number[]` | | Start and end scale on x-axis and y-axis. |
61+
| **scaleX** | `number[]` | | Start and end scale on x-axis. |
62+
| **scaleY** | `number[]` | | Start and end scale on y-axis. |
63+
| **scaleZ** | `number[]` | | Start and end scale on z-axis. |
6064
| **className** | `string` | | Optionally pass additional class names to be added to the outermost parallax element. |
6165
| **disabled** | `boolean` | `false` | Disables parallax effects on individual elements when `true`. |
6266
| **styleInner** | `object` | | Optionally pass a style object to be added to the innermost parallax element. |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
}
7575
],
7676
"dependencies": {
77-
"parallax-controller": "0.1.11"
77+
"parallax-controller": "0.1.13"
7878
},
7979
"devDependencies": {
8080
"@babel/core": "^7.16.0",

src/components/Parallax.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,39 @@ export interface ParallaxProps {
9696
* Second value is the ending scale
9797
*/
9898
scale?: number[];
99+
/**
100+
* Start and end scale on x-axis
101+
*
102+
* Example:
103+
*
104+
* scaleX={[0, 1]}
105+
*
106+
* First value is the starting scale
107+
* Second value is the ending scale
108+
*/
109+
scaleX?: number[];
110+
/**
111+
* Start and end scale on y-axis
112+
*
113+
* Example:
114+
*
115+
* scaleY={[0, 1]}
116+
*
117+
* First value is the starting scale
118+
* Second value is the ending scale
119+
*/
120+
scaleY?: number[];
121+
/**
122+
* Start and end scale on z-axis
123+
*
124+
* Example:
125+
*
126+
* scaleZ={[0, 1]}
127+
*
128+
* First value is the starting scale
129+
* Second value is the ending scale
130+
*/
131+
scaleZ?: number[];
99132
/**
100133
* Optionally pass additional class names to be added to the outermost parallax element.
101134
*/
@@ -176,6 +209,9 @@ export function Parallax(props: PropsWithChildren<ParallaxProps>) {
176209
rotateY: props.rotateY,
177210
rotateZ: props.rotateZ,
178211
scale: props.scale,
212+
scaleX: props.scaleX,
213+
scaleY: props.scaleY,
214+
scaleZ: props.scaleZ,
179215
}),
180216
};
181217
}
@@ -211,6 +247,9 @@ export function Parallax(props: PropsWithChildren<ParallaxProps>) {
211247
props.rotateY,
212248
props.rotateZ,
213249
props.scale,
250+
props.scaleX,
251+
props.scaleY,
252+
props.scaleZ,
214253
props.speed,
215254
]);
216255

stories/Parallax/4_ParallaxScale.stories.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,29 @@ const Template = (args) => {
1616
};
1717

1818
export const WithScale = Template.bind({});
19+
1920
WithScale.args = {
2021
scale: [0, 1],
2122
};
2223

24+
export const WithScaleX = Template.bind({});
25+
26+
WithScaleX.args = {
27+
scaleX: [0, 1],
28+
};
29+
30+
export const WithScaleY = Template.bind({});
31+
32+
WithScaleY.args = {
33+
scaleY: [0, 1],
34+
};
35+
36+
export const WithScaleZ = Template.bind({});
37+
38+
WithScaleZ.args = {
39+
scaleZ: [0, 1],
40+
};
41+
2342
export default {
2443
title: '<Parallax> Scale',
2544
component: WithScale,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11050,10 +11050,10 @@ pako@~1.0.5:
1105011050
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
1105111051
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==
1105211052

11053-
parallax-controller@0.1.11:
11054-
version "0.1.11"
11055-
resolved "https://registry.yarnpkg.com/parallax-controller/-/parallax-controller-0.1.11.tgz#405a48fcb912f4f914567d794b0224f9aca09b45"
11056-
integrity sha512-mT6H3A8oz/LctdwSN2sPMqsos1orD9jwkB5m0n5v5XDTYJgOGAA/rypAf2cEZ34J2z4NUIzgd5o07RBUKiA9xA==
11053+
parallax-controller@0.1.13:
11054+
version "0.1.13"
11055+
resolved "https://registry.yarnpkg.com/parallax-controller/-/parallax-controller-0.1.13.tgz#5e93b76cc849f1f96ee5915d547a0c98f3b244ff"
11056+
integrity sha512-rvUBtY/ebt5Z3hK6cZ9n2LoeYn5+AeZ273/UZbXuQFcgCizQtFt7x1/8zb4BrL09EwFWsx+HSQD2gg2UwzUicg==
1105711057

1105811058
parallel-transform@^1.1.0:
1105911059
version "1.2.0"

0 commit comments

Comments
 (0)