@@ -7,6 +7,7 @@ import styles from './Parallax.module.scss';
77import { useRef } from 'react' ;
88import { CSSEffect } from 'parallax-controller' ;
99import { useState } from 'react' ;
10+ import { ParallaxProps } from '../../src/components/Parallax/types' ;
1011
1112export const WithYOffsets = ( args ) => {
1213 const a = args . y1 . split ( ',' ) ;
@@ -175,31 +176,38 @@ StartAnimationAtInitialPosition.args = {
175176 endTranslateX : - 80 ,
176177} ;
177178
179+ const propConfigs : ParallaxProps [ ] = [
180+ {
181+ translateY : [ `100%` , `-100%` , 'easeInOutQuad' ] ,
182+ translateX : [ `100%` , `-100%` ] ,
183+ } ,
184+ { translateY : [ `-100%` , `100%` ] , translateX : [ `-100%` , `100%` ] } ,
185+ { scale : [ 0 , 1 ] , translateX : [ `-100%` , `100%` ] } ,
186+ { scale : [ 1 , 0 , 'easeInCubic' ] , translateY : [ `-100%` , `100%` ] } ,
187+ { rotate : [ 0 , 360 ] , scale : [ 1 , 0 , 'easeInOutBack' ] } ,
188+ { rotate : [ 0 , - 360 , 'easeInExpo' ] , scale : [ 0 , 1 ] } ,
189+ { translateY : [ `-100%` , `100%` ] , rotateY : [ 0 , 360 ] } ,
190+ {
191+ translateX : [ `-100%` , `100%` , 'easeInCubic' ] ,
192+ opacity : [ 0 , 1 , 'easeInCubic' ] ,
193+ } ,
194+ ] ;
195+
178196export const WithAHundredElements = ( ) => {
179197 const amount = 100 ;
180- const offset = 50 ;
181198 const elements = new Array ( amount ) . fill ( null ) . map ( ( x , i ) => i ) ;
182199
183200 return (
184201 < Container scrollAxis = "vertical" >
185202 < div className = { styles . elements } >
186203 { elements . map ( ( _ , i ) => {
187- const even = i % 2 === 0 ;
188- const props = {
189- translateX : [
190- even ? `${ offset } %` : `${ - offset } %` ,
191- even ? `${ - offset } %` : `${ offset } %` ,
192- ] ,
193- translateY : [
194- even ? `${ offset } %` : `${ - offset } %` ,
195- even ? `${ - offset } %` : `${ offset } %` ,
196- ] ,
197- } ;
198-
204+ const props : ParallaxProps = propConfigs [ i % propConfigs . length ] ;
199205 return (
200- < Parallax key = { i } className = { styles . small } { ...props } >
201- < Element name = { i + 1 } />
202- </ Parallax >
206+ < div key = { i } className = { styles . small } style = { { perspective : 800 } } >
207+ < Parallax { ...props } >
208+ < Element name = { i + 1 } />
209+ </ Parallax >
210+ </ div >
203211 ) ;
204212 } ) }
205213 </ div >
0 commit comments