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
Dragging and sorting in both directions? #593
Comments
Here you go @jr69 OliverJAsh/react-dnd-sortable-simple@9ebcabe |
What we did with our team is the following and it's working ok: (based on @OliverJAsh and the original, done some tweaks)
Thanks to all! Juan |
thanks @juampick , @OliverJAsh 👍 |
I've managed to make it work as expected, inspired by @OliverJAsh's commit:
|
thanks for your code, can you maybe explain where you get the Cheers |
@tizzle
You need to pass in
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This solution helped me a lot. You can drag and drop any direction without any hassle. Also, to get beginDrag(props, monitor, component) {
// `getNode` comes from `useImperativeHandle` suggested by ReactDnD
const node = component.getNode();
const dragBoundingRect = node.getBoundingClientRect();
return {
// ....
dragBoundingRect
};
} Then easily retrieve it from |
I've looked at the example sortable list and have managed to make it work horizontal, by having the divs display in inline-block, and then changing the "Draggable-XXX" file's cardTarget, hover() method, to have X variables instead of Y.
Is there a way to somehow make react-dnd detect both direction dragging? I am currently trying putting this:
// Dragging downwards if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) { return; } // Dragging upwards if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) { return; } // Dragging left if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) { return; } // Dragging right if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) { return; }
but to no avail, the dragging is really buggy, sometimes it won't even swap the elements, and I have to move the mouse around like crazy to get some registration/feedback
The text was updated successfully, but these errors were encountered: