Skip to content

Commit 2354e46

Browse files
committed
return controller and element in hook
1 parent a0ab4ba commit 2354e46

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/hooks/useParallax.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ export function useParallax<T extends HTMLElement>(props: ParallaxProps) {
1212
useVerifyController(controller);
1313

1414
function _getElementOptions(): CreateElementOptions {
15-
const useSpeedProp = typeof props.speed !== 'undefined';
15+
const shouldUseSpeedProp = typeof props.speed !== 'undefined';
1616
const isHorizontal = controller?.scrollAxis == 'horizontal';
1717
const isVertical = controller?.scrollAxis == 'vertical';
1818

1919
let translateX = props.translateX;
2020
let translateY = props.translateY;
2121

2222
// TODO: move to parallax-controller
23-
if (useSpeedProp && isHorizontal) {
23+
if (shouldUseSpeedProp && isHorizontal) {
2424
translateX = [
2525
`${(props.speed || 0) * 10}px`,
2626
`${(props.speed || 0) * -10}px`,
2727
];
2828
}
2929

30-
if (useSpeedProp && isVertical) {
30+
if (shouldUseSpeedProp && isVertical) {
3131
translateY = [
3232
`${(props.speed || 0) * 10}px`,
3333
`${(props.speed || 0) * -10}px`,
@@ -115,5 +115,5 @@ export function useParallax<T extends HTMLElement>(props: ParallaxProps) {
115115
props.targetElement,
116116
]);
117117

118-
return { ref };
118+
return { ref, controller, element };
119119
}

0 commit comments

Comments
 (0)