dnd-kit-sortable-tree
Version:
[](https://www.npmjs.org/package/dnd-kit-sortable-tree) [](https://www.npmjs.org/package/dnd-kit-sortable-tree) [ • 588 B
text/typescript
import {
SortingStrategy,
verticalListSortingStrategy,
} from '@dnd-kit/sortable';
export const customListSortingStrategy = (
isValid: (activeIndex: any, overIndex: any) => boolean
): SortingStrategy => {
const sortingStrategy: SortingStrategy = ({
activeIndex,
activeNodeRect,
index,
rects,
overIndex,
}) => {
if (isValid(activeIndex, overIndex)) {
return verticalListSortingStrategy({
activeIndex,
activeNodeRect,
index,
rects,
overIndex,
});
}
return null;
};
return sortingStrategy;
};