npm.io
0.5.0 • Published 4 months ago

@dnd-kit/helpers

Licence
MIT
Version
0.5.0
Deps
0
Vulns
0
Weekly
0
Stars
17.7K

@dnd-kit/helpers

Stable release

Framework-agnostic helper functions for @dnd-kit. Provides utilities for common data transformations in drag and drop interactions.

Installation

npm install @dnd-kit/helpers

API

Function Description
move(items, event) Move an item from one position to another within a flat or grouped collection
swap(items, event) Swap the positions of two items
arrayMove(array, from, to) Move an item in an array from one index to another
arraySwap(array, from, to) Swap two items in an array by index
Example
import {move} from '@dnd-kit/helpers';

function onDragEnd(event) {
  items = move(items, event);
}

Documentation

Visit dndkit.com for full documentation.