UNPKG

dnd-kit-sortable-tree

Version:

[![npm version](https://badge.fury.io/js/dnd-kit-sortable-tree.svg)](https://www.npmjs.org/package/dnd-kit-sortable-tree) [![npm](https://img.shields.io/npm/dt/dnd-kit-sortable-tree.svg)](https://www.npmjs.org/package/dnd-kit-sortable-tree) [![MIT](https:

28 lines (27 loc) 588 B
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; };