Skip to content

Commit 78e0f96

Browse files
committed
extend ParallaxElementConfig for Parallax props
1 parent 3a77c2d commit 78e0f96

File tree

2 files changed

+3
-171
lines changed

2 files changed

+3
-171
lines changed

src/components/Parallax/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export function Parallax(props: PropsWithChildren<ParallaxProps>) {
4040
// @ts-expect-error
4141
elOuter: refOuter.current,
4242
props: removeUndefinedObjectKeys({
43-
disabled: props.disabled,
4443
translateX,
4544
translateY,
45+
disabled: props.disabled,
4646
rotate: props.rotate,
4747
rotateX: props.rotateX,
4848
rotateY: props.rotateY,

src/components/Parallax/types.ts

+2-170
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { RootMarginShape, ValidEasingPresets } from 'parallax-controller';
1+
import { ParallaxElementConfig } from 'parallax-controller';
22

3-
export interface ParallaxProps {
3+
export interface ParallaxProps extends ParallaxElementConfig {
44
/**
55
* A number to slowdown `n < 0` or speed up `n > 0` the scroll speed of an element
66
*
@@ -10,147 +10,6 @@ export interface ParallaxProps {
1010
*
1111
*/
1212
speed?: number;
13-
/**
14-
* Start and end translation on x-axis in % or px. If no unit is passed percent is assumed. Percent is based on the elements width.
15-
*
16-
* Example:
17-
*
18-
* translateX={[-100, 100]}
19-
*
20-
* First value is the starting translation
21-
* Second value is the ending translation
22-
*/
23-
translateX?: string[] | number[];
24-
/**
25-
* Start and end translation on y-axis in % or px. If no unit is passed percent is assumed. Percent is based on the elements height.
26-
*
27-
* Example:
28-
*
29-
* translateY={[-100, 100]}
30-
*
31-
* First value is the starting translation
32-
* Second value is the ending translation
33-
*/
34-
translateY?: string[] | number[];
35-
36-
/**
37-
* Start and end rotation on z-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed.
38-
*
39-
* Example:
40-
*
41-
* rotate={['0deg', '360deg']}
42-
*
43-
* First value is the starting rotation
44-
* Second value is the ending rotation
45-
*/
46-
rotate?: string[] | number[];
47-
/**
48-
* Start and end rotation on x-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed.
49-
*
50-
* Example:
51-
*
52-
* rotateX={['0deg', '360deg']}
53-
*
54-
* First value is the starting rotation
55-
* Second value is the ending rotation
56-
*/
57-
rotateX?: string[] | number[];
58-
/**
59-
* Start and end rotation on y-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed.
60-
*
61-
* Example:
62-
*
63-
* rotateY={['0deg', '360deg']}
64-
*
65-
* First value is the starting rotation
66-
* Second value is the ending rotation
67-
*/
68-
rotateY?: string[] | number[];
69-
/**
70-
* Start and end rotation on z-axis in `deg`, `rad`, or `turn`. If no unit is passed `deg` is assumed.
71-
*
72-
* Example:
73-
*
74-
* rotateZ={['0deg', '360deg']}
75-
*
76-
* First value is the starting rotation
77-
* Second value is the ending rotation
78-
*/
79-
rotateZ?: string[] | number[];
80-
81-
/**
82-
* Start and end scale on x-axis and y-axis.
83-
*
84-
* Example:
85-
*
86-
* scale={[0, 1]}
87-
*
88-
* First value is the starting scale
89-
* Second value is the ending scale
90-
*/
91-
scale?: number[];
92-
/**
93-
* Start and end scale on x-axis
94-
*
95-
* Example:
96-
*
97-
* scaleX={[0, 1]}
98-
*
99-
* First value is the starting scale
100-
* Second value is the ending scale
101-
*/
102-
scaleX?: number[];
103-
/**
104-
* Start and end scale on y-axis
105-
*
106-
* Example:
107-
*
108-
* scaleY={[0, 1]}
109-
*
110-
* First value is the starting scale
111-
* Second value is the ending scale
112-
*/
113-
scaleY?: number[];
114-
/**
115-
* Start and end scale on z-axis
116-
*
117-
* Example:
118-
*
119-
* scaleZ={[0, 1]}
120-
*
121-
* First value is the starting scale
122-
* Second value is the ending scale
123-
*/
124-
scaleZ?: number[];
125-
/**
126-
* Start and end opacity value
127-
*
128-
* Example:
129-
*
130-
* opacity={[0, 1]}
131-
*
132-
* First value is the starting opacity
133-
* Second value is the ending opacity
134-
*/
135-
opacity?: number[];
136-
/**
137-
* Easing preset or custom params for a cubic bezier easing function.
138-
*
139-
* Example preset: 'easeInOut'
140-
* Example params: [0.42, 0, 0.58, 1]
141-
*/
142-
easing?: number[] | ValidEasingPresets;
143-
/**
144-
* Margin to be applied as the bounds around an element.
145-
* This will affect when an element is determined to be considered in the viewport.
146-
*
147-
* Example: rootMargin={{ top: 100, right: 100, bottom: 100, left: 100 }}
148-
*/
149-
rootMargin?: RootMarginShape;
150-
/**
151-
* Will start the animation at initial element position if the element is positioned inside the view when scroll is at zero
152-
*/
153-
shouldStartAnimationInitialInView?: boolean;
15413
/**
15514
* Class names to be added to the outermost parallax element.
15615
*/
@@ -159,10 +18,6 @@ export interface ParallaxProps {
15918
* Class names to be added to the outermost parallax element.
16019
*/
16120
innerClassName?: string;
162-
/**
163-
* Disables parallax effects on individual elements when true.
164-
*/
165-
disabled?: boolean;
16621
/**
16722
* Style object to be added to the innermost parallax element.
16823
*/
@@ -179,27 +34,4 @@ export interface ParallaxProps {
17934
* HTML element tag name to be applied to the outermost parallax element.
18035
*/
18136
tag?: any;
182-
183-
/**
184-
* Scroll top value to begin the animation. When provided along with `endScroll` relative scroll values will be ignored.
185-
*/
186-
startScroll?: number;
187-
188-
/**
189-
* Scroll top value to end the animation. When provided along with `startScroll` relative scroll values will be ignored.
190-
*/
191-
endScroll?: number;
192-
193-
/**
194-
* Callback for when the progress of an element in the viewport changes.
195-
*/
196-
onProgressChange?: (progress: number) => any;
197-
/**
198-
* Callback for when an element enters the viewport.
199-
*/
200-
onEnter?: () => any;
201-
/**
202-
* Callback for when an element exits the viewport.
203-
*/
204-
onExit?: () => any;
20537
}

0 commit comments

Comments
 (0)