Skip to content

Commit 1e7c4e5

Browse files
committed
rotation story
1 parent 021daba commit 1e7c4e5

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
}
7474
],
7575
"dependencies": {
76-
"parallax-controller": "0.1.8"
76+
"parallax-controller": "0.1.9"
7777
},
7878
"devDependencies": {
7979
"@babel/core": "^7.16.0",

src/components/Parallax.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ export interface ParallaxProps {
2929
* Second value is the ending translation
3030
*/
3131
y?: string[] | number[];
32+
33+
/**
34+
* Start and end rotation on z-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed.
35+
*
36+
* Example:
37+
*
38+
* rotate={['0deg', '360deg']}
39+
*
40+
* First value is the starting rotation
41+
* Second value is the ending rotation
42+
*/
43+
rotate?: string[] | number[];
3244
/**
3345
* Optionally pass additional class names to be added to the outermost parallax element.
3446
*/
@@ -84,6 +96,7 @@ export function Parallax(props: PropsWithChildren<ParallaxProps>) {
8496
// Defaults set in Parallax.defaultProps
8597
translateX: props.x,
8698
translateY: props.y,
99+
rotate: props.rotate,
87100
},
88101
};
89102
}

stories/Parallax/1_ParallaxVertical.stories.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ import { Container } from '../Container';
55
import { ScrollContainer } from '../ScrollContainer';
66
import styles from './Parallax.module.scss';
77

8+
export const WithRotation = (args) => {
9+
const a = args.rotate1.split(',');
10+
const b = args.rotate2.split(',');
11+
return (
12+
<Container scrollAxis="vertical" className={styles.elements}>
13+
<Parallax rotate={a} className={styles.parallax}>
14+
<Element name="1" />
15+
</Parallax>
16+
<Parallax rotate={b} className={styles.parallax}>
17+
<Element name="2" />
18+
</Parallax>
19+
</Container>
20+
);
21+
};
22+
23+
WithRotation.args = {
24+
rotate1: '0deg,360deg',
25+
rotate2: '0deg,-360deg',
26+
};
27+
828
export const WithYOffsets = (args) => {
929
const a = args.y1.split(',');
1030
const b = args.y2.split(',');

yarn.lock

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

10156-
parallax-controller@0.1.8:
10157-
version "0.1.8"
10158-
resolved "https://registry.yarnpkg.com/parallax-controller/-/parallax-controller-0.1.8.tgz#487d3ff24c93cab757c4fd9f90611393d9f83b19"
10159-
integrity sha512-8pY64e0yMrpB9XQLzNqSdGdlT13PwhZnOwoA54KoK5oFnuAPrAV2/CwhPCKOGVsyuBfW6N1ginXm9p+pX0V86w==
10156+
parallax-controller@0.1.9:
10157+
version "0.1.9"
10158+
resolved "https://registry.yarnpkg.com/parallax-controller/-/parallax-controller-0.1.9.tgz#3fb47409a3aded7dc067d8ddde530cab5d622562"
10159+
integrity sha512-czH4ic3IQIerN7Wt3uPgY0UkZYT0BihQroREQel8rBGK2Jj0mltmS6Dvc5io9T38pg6L5AcLVVbnM5F9mw1LrQ==
1016010160

1016110161
parallel-transform@^1.1.0:
1016210162
version "1.2.0"

0 commit comments

Comments
 (0)