-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
UI issues during drag #2033
Comments
Happens to me to |
see #128 (comment) for an unofficial work around |
Hello! It's been almost two years. Are there any updates? |
I had this problem, could not fix it so I created a component that smoothly follows the cursor that I set at the same level in the hierarchy as DragDropContext const ImageFollowCursor = ({ src }) => {
const mouseListener1 = (e) => {
const circle = document.getElementById('circle');
const left = e.clientX;
const top = e.clientY;
circle.style.transform = `translate(${left}px, ${top}px)`;
};
useEffect(() => {
document.addEventListener('mousemove', mouseListener1);
return () => {
document.removeEventListener('mousemove', mouseListener1);
};
}, [src]);
return (
<img
id="circle"
aria-label="cursor"
style={{
display: 'none',
objectFit: 'cover',
borderRadius: '10px',
opacity: 0.9,
position: 'fixed',
top: 0,
left: 0,
marginTop: '5px',
marginLeft: '5px',
width: '60px',
height: '60px',
pointerEvents: 'none',
zIndex: 999999,
transition: 'transform 0.1s',
transform: 'translate(0, 0)'
}}
/>
);
}; And I modified the handlers onDragUpdate and onDragEnd like so const onDragUpdate = (result) => {
const circle = document.getElementById('circle');
if (circle) {
const draggingElement = mediaList.find((m) => m.id === result.draggableId);
circle.src = draggingElement?.get('thumbnailUrl');
circle.style.display = 'block';
}
// Rest of the handler...
}
const onDragEnd = (result) => {
const circle = document.getElementById('circle');
if (circle) {
circle.src = null;
circle.style.display = 'none';
}
// Rest of the handler...
} |
Expected behavior
I expect dragging to be as smooth as ordinary.
Actual behavior
However, when I start dragging anything located with a Callout, Panel or a Dialog (these all are components from Fluent UI) there is a strange offset that actually becomes bigger when the element is located more to the right of the screen.
Steps to reproduce
I have prepared two GIFs visualizing the problem.
Also, I have created a repository whit the minimum required for a valuable code sample representing the problem: https://github.com/TonyTroeff/issue-with-react-beautiful-dnd
What version of
React
are you using?The code sample provided uses React v17.0.1, but I can ensure you that it behaves the same way in old versions too. The main project where this was found as an issue runs on v16.13.1
What version of
react-beautiful-dnd
are you running?Both projects use latest version - 13.0.0
What browser are you using?
I tested this in all browsers that I could - Edge, Chrome, Firefox and Brave.
The text was updated successfully, but these errors were encountered: