react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

Sorting happens while mousedown after the drag movement ends

Open mmela opened this issue 9 years ago • 1 comments

Hi everyone,

I'm experiencing following with a grid setup:

  1. Start drag with mousedown --> other items in the grid make space nicely
  2. Movement stops (still mousedown) --> items return to their positions instead of keeping the space as in 1)
  3. 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.

mmela avatar Feb 21 '17 09:02 mmela

Could you provide a jsfiddle?

Robinfr avatar Feb 21 '17 10:02 Robinfr