Comments (5)
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 :)
from solid-dnd.
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;
};
from solid-dnd.
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 flex flex-row items-center gap-1
Tailwind styles for the container.
Screen.Recording.2022-09-24.at.00.45.30.mov
from solid-dnd.
Same here. Everything else is working great, but this makes things look quite ugly at times.
Haven't looked into this much, but could we steal some logic from here https://master--5fc05e08a4a65d0021ae0bf2.chromatic.com/?path=/story/presets-sortable-vertical--variable-heights maybe?
Would love to see this "fixed" soon.
Thank you for making and maintaining this library.
from solid-dnd.
Hey. Lib is wonderful, but this issue is the first thing that catches your eye. Has anyone found any solution?
from solid-dnd.
Related Issues (20)
- Bento Draggable Layout HOT 2
- attach is used before it is defined HOT 1
- Non deterministic order of events onDragStart, onDragOver, onDragMove
- solid-dnd.com is down! HOT 2
- Get `useDragDropContext is not a function or its return value is not iterable` HOT 1
- TypeError: useDragDropContext is not a function or its return value is not iterable at createDroppable HOT 8
- Scrolling when nearing top/bottom of droppable container / sortable container. HOT 1
- Sortable with Draghandle HOT 4
- Placeholder at the beginning of a drag HOT 1
- createDraggable and createDroppable are not reactive HOT 2
- Conditionally Prevent Drag HOT 1
- Draggable SVG shape moves faster than pointer HOT 4
- Unable to load data dynamically. Please help HOT 2
- Recompute layouts on remove
- Access state and actions from callback handlers
- Get current droppable on onDragMove HOT 1
- Only the text is visible on the dragged element HOT 1
- Add support for sortables of irregular sizes. HOT 4
- Beginners Documentation HOT 10
- Trying to render a custom component as sortable HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solid-dnd.