Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Dock component: useTransform #376

Open
jercomio opened this issue Oct 14, 2024 · 3 comments
Open

[BUG] Dock component: useTransform #376

jercomio opened this issue Oct 14, 2024 · 3 comments

Comments

@jercomio
Copy link

For Next.js (latest) application, there is a bug because the property mouseX is undefined (line 86, dock.tsx). See the declare function useTransform in index.d.tsfile. input: MotionValue<I> must be an array like the example : const z = useTransform([x, y], ([latestX, latestY]) => latestX * latestY)

So, to resolve this bug, write mouseX = [] instead of mouseX.

const DockIcon = ({
  size,
  magnification = DEFAULT_MAGNIFICATION,
  distance = DEFAULT_DISTANCE,
  mouseX = [],
  className,
  children,
  ...props
}: DockIconProps) => {
  const ref = useRef<HTMLDivElement>(null);

  const distanceCalc = useTransform(mouseX, (val: number) => {
    const bounds = ref.current?.getBoundingClientRect() ?? { x: 0, width: 0 };

    return val - bounds.x - bounds.width / 2;
  });
@jercomio jercomio changed the title [DOCK] Dock component: BUG, useTransform [BUG] Dock component: useTransform Oct 14, 2024
@Willy-Bueno
Copy link

@jercomio You probably didn't pass "use client" in your page or component. If you pass a fazio array it should probably work, but you will lose the effects of the dock.

@maq796113
Copy link

I have fixed the bug

@rafai123
Copy link

Thanks all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants