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] The variants prevent drag transformation #2807

Open
programming-with-ia opened this issue Sep 20, 2024 · 1 comment
Open

[BUG] The variants prevent drag transformation #2807

programming-with-ia opened this issue Sep 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@programming-with-ia
Copy link

Issue: Dragging Disabled When Applying none Variant with Custom Transform

When using the following variants:

const variants: Variants = {
  // ...other variants
  none: (custom) => ({
    width: "fit-content",
    height: "fit-content",
    transform: custom || undefined,
  }),
} as const;

I apply the none variant with a custom transform. The custom transform is supposed to restore the position to a previous drag state. However, when the none variant is applied, it disables the drag transformation, preventing the window from moving.

Minimal Code Example

<motion.div
  ref={winRef}
  custom={positionBackup.current}
  initial="none"
  animate={isMaximize ? "maximize" : "none"}
  variants={variants}
  drag={!isMaximize}
  dragListener={false}
  dragControls={dragControls}
  dragMomentum={false}
  dragConstraints={winContainer ?? {}}
></motion.div>;

More Details

I am building a window component similar to a Windows OS window. I want the user to drag the window using the title bar.

image

@programming-with-ia programming-with-ia added the bug Something isn't working label Sep 20, 2024
@programming-with-ia programming-with-ia changed the title [BUG] variants disabled drag transformation [BUG] The variants prevent drag transformation Sep 20, 2024
@programming-with-ia
Copy link
Author

this heppens only when value assign as string
also issue with other properties like height & width

that's working for me but need current feature

const variants:Variants = {
    // others
    none: custom => ({height: "auto", ...(custom ? {x: custom.x, y: custom.y}: {})})
  } as const

but in case of 3d case an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant