|
| 1 | +import React from 'react'; |
| 2 | +import { useParallax } from '../../src'; |
| 3 | +import { Element } from '../Element/Element'; |
| 4 | +import { Container } from '../Container'; |
| 5 | +import styles from '../Parallax/Parallax.module.scss'; |
| 6 | + |
| 7 | +const Template = (args) => { |
| 8 | + const props = Object.entries(args).reduce((acc: any, entry: any) => { |
| 9 | + acc[entry[0]] = entry[1].split(','); |
| 10 | + return acc; |
| 11 | + }, {} as any); |
| 12 | + |
| 13 | + const { ref } = useParallax<HTMLDivElement>(props); |
| 14 | + |
| 15 | + return ( |
| 16 | + <div className={styles.parallax} ref={ref}> |
| 17 | + <Element name="A" /> |
| 18 | + </div> |
| 19 | + ); |
| 20 | +}; |
| 21 | + |
| 22 | +export const WithRotation = Template.bind({}); |
| 23 | +WithRotation.args = { |
| 24 | + rotate: '0deg,360deg', |
| 25 | +}; |
| 26 | + |
| 27 | +export const WithRotationX = Template.bind({}); |
| 28 | +WithRotationX.args = { |
| 29 | + rotateX: '0deg,360deg', |
| 30 | +}; |
| 31 | + |
| 32 | +export const WithRotationY = Template.bind({}); |
| 33 | +WithRotationY.args = { |
| 34 | + rotateY: '0deg,360deg', |
| 35 | +}; |
| 36 | + |
| 37 | +export const WithRotationZ = Template.bind({}); |
| 38 | +WithRotationZ.args = { |
| 39 | + rotateZ: '0deg,360deg', |
| 40 | +}; |
| 41 | + |
| 42 | +export const WithRotationXY = Template.bind({}); |
| 43 | +WithRotationXY.args = { |
| 44 | + rotateX: '0deg,360deg', |
| 45 | + rotateY: '0deg,360deg', |
| 46 | +}; |
| 47 | + |
| 48 | +export const WithRotationXZ = Template.bind({}); |
| 49 | +WithRotationXZ.args = { |
| 50 | + rotateX: '0deg,360deg', |
| 51 | + rotateZ: '0deg,360deg', |
| 52 | +}; |
| 53 | + |
| 54 | +export const WithRotationYZ = Template.bind({}); |
| 55 | +WithRotationYZ.args = { |
| 56 | + rotateY: '0deg,360deg', |
| 57 | + rotateZ: '0deg,360deg', |
| 58 | +}; |
| 59 | + |
| 60 | +export const WithRotationXYZ = Template.bind({}); |
| 61 | +WithRotationXYZ.args = { |
| 62 | + rotateX: '0deg,360deg', |
| 63 | + rotateY: '0deg,360deg', |
| 64 | + rotateZ: '0deg,360deg', |
| 65 | +}; |
| 66 | + |
| 67 | +export const WithTranslateYAndRotation = Template.bind({}); |
| 68 | +WithTranslateYAndRotation.args = { |
| 69 | + translateY: '-100,100', |
| 70 | + rotate: '0deg,360deg', |
| 71 | +}; |
| 72 | + |
| 73 | +export default { |
| 74 | + title: 'Components / useParallax / Rotate Props', |
| 75 | + component: WithRotation, |
| 76 | + decorators: [ |
| 77 | + (Story) => ( |
| 78 | + <Container scrollAxis="vertical" className={styles.elements}> |
| 79 | + <Story /> |
| 80 | + </Container> |
| 81 | + ), |
| 82 | + ], |
| 83 | +}; |
0 commit comments