Skip to content

Commit bd66fa5

Browse files
committed
feat: bump controller to latest and use built in speed prop handling
1 parent 8c1ce2a commit bd66fa5

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
}
8484
],
8585
"dependencies": {
86-
"parallax-controller": "^1.0.3"
86+
"parallax-controller": "^1.1.0"
8787
},
8888
"devDependencies": {
8989
"@babel/core": "^7.16.0",

src/hooks/useParallax.ts

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

1414
function _getElementOptions(): CreateElementOptions {
15-
const shouldUseSpeedProp = typeof props.speed !== 'undefined';
16-
const isHorizontal = controller?.scrollAxis == 'horizontal';
17-
const isVertical = controller?.scrollAxis == 'vertical';
18-
19-
let translateX = props.translateX;
20-
let translateY = props.translateY;
21-
22-
// TODO: move to parallax-controller
23-
if (shouldUseSpeedProp && isHorizontal) {
24-
translateX = [
25-
`${(props.speed || 0) * 10}px`,
26-
`${(props.speed || 0) * -10}px`,
27-
];
28-
}
29-
30-
if (shouldUseSpeedProp && isVertical) {
31-
translateY = [
32-
`${(props.speed || 0) * 10}px`,
33-
`${(props.speed || 0) * -10}px`,
34-
];
35-
}
36-
3715
return {
3816
// @ts-expect-error
3917
el: ref.current,
4018
props: removeUndefinedObjectKeys({
41-
translateX,
42-
translateY,
19+
speed: props.speed,
20+
translateX: props.translateX,
21+
translateY: props.translateY,
4322
disabled: props.disabled,
4423
rotate: props.rotate,
4524
rotateX: props.rotateX,

yarn.lock

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

10916-
parallax-controller@^1.0.3:
10917-
version "1.0.3"
10918-
resolved "https://registry.yarnpkg.com/parallax-controller/-/parallax-controller-1.0.3.tgz#db67d90222130f959ad3d110d8a68c65bcd561ca"
10919-
integrity sha512-P9DoUV/vh7Ipt+RNwUdmRyV6gA7eTfYg/7RmQovIsEEYL7uHRUE96KBDJabMZElw3/3TjrC52/m+ZlBF0ZekEw==
10916+
parallax-controller@^1.1.0:
10917+
version "1.1.0"
10918+
resolved "https://registry.yarnpkg.com/parallax-controller/-/parallax-controller-1.1.0.tgz#134114855d45665f73f3b366009846f8f446a105"
10919+
integrity sha512-7S9YrlIkIdFqigZpYVIjjRrGhSDBXa+tR++CL5tSjNotGSlJCn2148IeMy6+xIDi1zzjhnTY5ZJwQi/Ie9zYTg==
1092010920
dependencies:
1092110921
bezier-easing "^2.1.0"
1092210922

0 commit comments

Comments
 (0)