react-sortable-hoc
react-sortable-hoc copied to clipboard
Sorting happens while mousedown after the drag movement ends
Hi everyone,
I'm experiencing following with a grid setup:
- Start drag with mousedown --> other items in the grid make space nicely
- Movement stops (still mousedown) --> items return to their positions instead of keeping the space as in 1)
- mousedown released --> Dragged item gets positioned in the drag location (as it should)
render():
<SortableList
items={this.state.imageBlocks}
axis="xy"
pressDelay={200}
shouldCancelStart={this.shouldCancelStart}
onSortEnd={this.onSortEnd}
helperClass="SortableHelper" />
SortableItem and SortableList:
const SortableItem = SortableElement(({index, item}) => {
return (
<div className="image-block">
<div className="image-block-container">
<Image src={item.src}/>
</div>
</div>
);
});
const SortableList = SortableContainer(({items}) => {
return (
<ul className="SortableList">
{items.map((item, index) =>
<SortableItem key={`item-${index}`} index={index} item={item} />
)}
</ul>
);
});
UPDATE: the SortableList needed display: flex;. Now everything works smoothly.
Could you provide a jsfiddle?