React-sortable-hoc: Selected element under on drag.

Created on 24 May 2017  路  6Comments  路  Source: clauderic/react-sortable-hoc

Example: http://rubaxa.github.io/Sortable/
Try to drag element and you'll see "ghost" element under draggable element.

Could we style "ghost" element like this?

Most helpful comment

With hideSortableGhost set to false the ghosted element remains fixed in place in its original position/cell/slot, and doesn't move to the new cell it's hovering over during a drag operation.
Is there a way to move it to the proposed location ahead of dropping it?

All 6 comments

You can achieve this by setting the hideSortableGhost prop to false on your enhanced SortableContainer component.

Then, you can store the index of the element currently being sorted onSortStart and apply some conditional styling from there.

Thank for some workaround, but it's not what I meant.

Hi @clauderic,

first of all thank you for your great HOC, i really like it.
i deleted my last message, as i thought i did a very stupid mistake (which i did).

But nonetheless i'm not sure if your suggestion can work. I'm not able to write the index to state in onSortStart, as it breaks the whole component. I get this error:

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the sortableList component.

When saving the index to a regular variable (i know, i shouldn't do that) i don't get any renders in react until onSortEnd.

Thus no conditional styling can be applied to SortableElement. Am i missing something?

Cheers

Till

Yeah I'm getting the same issue. If I do a setState in the onSortStart handler, the sorting breaks completely. Makes it impossible to pass the current sorting state down to the SortableElements

With hideSortableGhost set to false the ghosted element remains fixed in place in its original position/cell/slot, and doesn't move to the new cell it's hovering over during a drag operation.
Is there a way to move it to the proposed location ahead of dropping it?

Is there ability to move ghost with original dragged element?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccharliemagne picture ccharliemagne  路  3Comments

ricokahler picture ricokahler  路  3Comments

zaygraveyard picture zaygraveyard  路  3Comments

ianmstew picture ianmstew  路  3Comments

sami616 picture sami616  路  4Comments