-
Notifications
You must be signed in to change notification settings - Fork 36
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
Support variable sized sortables #32
Comments
For reference, this was the previous 'vertical' algorithm: const sortedTransform = (): Transform => {
const delta = noopTransform();
const resolvedInitialIndex = initialIndex();
const resolvedCurrentIndex = currentIndex();
if (
!anyDraggableActive() ||
resolvedCurrentIndex === resolvedInitialIndex
) {
return delta;
}
const draggableId = dndState.active.draggable!;
const draggableInitialIndex = sortableState.initialIds.indexOf(draggableId);
const draggableLayout = layoutById(draggableId)!;
if (draggable.isActiveDraggable) {
const droppableId = dndState.active.droppable!;
const droppableLayout = layoutById(droppableId)!;
if (resolvedCurrentIndex > resolvedInitialIndex) {
delta.y = droppableLayout.bottom - draggableLayout.bottom;
} else {
delta.y = droppableLayout.top - draggableLayout.top;
}
} else {
if (resolvedCurrentIndex > resolvedInitialIndex) {
const leadingId = sortableState.initialIds[draggableInitialIndex - 1];
const leadingLayout = layoutById(leadingId)!;
const leadingGap = draggableLayout.top - leadingLayout.bottom;
delta.y += draggableLayout.height + leadingGap;
} else {
const trailingId = sortableState.initialIds[draggableInitialIndex + 1];
const trailingLayout = layoutById(trailingId)!;
const trailingGap = trailingLayout.top - draggableLayout.bottom;
delta.y -= draggableLayout.height + trailingGap;
}
}
return delta;
}; |
Very much looking forward to this! Currently, it's the only thing that seems to be not working for me. Here is how dragging looks for the variable-sized sortables with the Screen.Recording.2022-09-24.at.00.45.30.mov |
Same here. Everything else is working great, but this makes things look quite ugly at times. Would love to see this "fixed" soon. |
Thanks for the kind words. The logic you see in dnd-kit is similar to what I had before (see the example code at the top of this issue). However, I encountered some issues with it and will rethink the approach. Hopefully the overall improvements to the library I've made since will make this easier to solve :) |
Hey. Lib is wonderful, but this issue is the first thing that catches your eye. Has anyone found any solution? |
The current (0.6.0) Sortable algorithm requires items to be the same dimensions for correct visual sorting. Otherwise, gaps and overlays occur. The previous algorithm attempted to handle this (for specific vertical orientation), but still had issues (e.g. #9) .
Try a holistic approach to this instead.
The text was updated successfully, but these errors were encountered: