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

Strange "Ghost" Silhouette of Draggable Element When Using Non-integer (i.e., numbers with decimals) #744

Open
husky-blue opened this issue Mar 21, 2024 · 0 comments

Comments

@husky-blue
Copy link

If you set the state of a Draggable element's position to a non-integer (i.e., a number with decimals, like 123.4), you will get a strange silhouette of the element when dragging it. Consider this example:

import { useState } from 'react';

interface PositionModel {
  x: number;
  y: number;
}

const MyComponent = () => {
  const [pos, setPos] = useState({ x: 0, y: 0 } as PositionModel);
  const handleDragStop = (_e: DraggableEvent, position: DraggableData) => {
    setPos({ x: 456.2, y: 229.8 });
  };

  return (
    <Draggable
      position={pos}
      onStop={handleDragStop}
    >
      <div>I am an element</div>
    </Draggable>
  );
};

After the handleDragStop function is triggered and you go to drag the component again, you'll see something similar to this:

2024-03-21_15-35-18

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

1 participant