Open rjdecilos opened 4 years ago
@clauderic
Having the same issue. @rjdecilos I notice that you're not wrapping children
in a parent element. I'm curious if you're getting any console errors. I was doing something similar at first and the sortable helper only started working when I wrapped the sortable elements (inside the container) in a div:
const SortableContainer = sortableContainer(({ styles, children }) => {
return <Div styles={styles}>{children}</Div>;
});
That being said, I'm also seeing that the item being dragged isn't moving when I use lockToContainerEdges
.
Turns out I'm just an idiot. I was using lockAxis="x"
but didn't set axis="x"
, so once I added the axis
prop, lockToContainerEdges
started working. @rjdecilos I have a feeling that once you fix your container issue (missing wrapping element), or any other incorrect props, you'll see that lockToContainerEdges
starts to work.
Thank you for this, I'll try it out @mmichael0413
The item not moving is caused by translate3d
receiving NaN
values.
This issue may be caused by the following change to the limit
util:
Under some circumstances, limit
is called with undefined
for min
and max
.
The old code returned value
in this case, the new code returns NaN
.
For vertical dragging, the issue can be worked around by:
lockAxis="x"
, because this will override NaN
with 0
lockToContainerEdges
, because this will not run the limit
code in questionaxis="xy"
, because this will prevent undefined
arguments to limit
Item being dragged is not moving. I'm using the basic example to do this with the lockToContainerEdges prop. Sample code below:
`const SortableItem = sortableElement(({value}) => <li style={{ color: 'white'}}>{value});
const SortableContainer = sortableContainer(({children}) => { return
{children}
; });class App extends Component { state = { items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6'], };
onSortEnd = ({oldIndex, newIndex}) => { this.setState(({items}) => ({ items: arrayMove(items, oldIndex, newIndex), })); };
render() { const {items} = this.state;
} }`