Svelte Sortable List screenshot

Svelte Sortable List

Author Avatar Theme by Brunomolteni
Updated: 14 Jan 2020
124 Stars

A svelte 3 component that implements a list with animated drag-n-drop functionality.

Overview

The SortableList component is a versatile tool that allows users to render a list of items that can be reordered by dragging and dropping. It also implements the FLIP animation for smooth transitions when adding, removing, or reordering items in the list. To use this component, you need to set the list prop and respond to the on:reorder event.

Features

  • Drag and drop functionality for reordering items in the list.
  • FLIP animation for smooth transitions when adding, removing, or reordering items.
  • Customizable list item element.
  • Ability to access item data and index.

Installation

To install the SortableList component, follow these steps:

  1. Install the package using npm:
npm install sortable-list
  1. Import the SortableList component into your project:
import SortableList from 'sortable-list';
  1. Use the SortableList component in your code:
<SortableList list={myList} on:reorder={handleReorder} />

Make sure to replace myList with the actual list you want to render and handleReorder with the function that will be called when items are reordered.

Summary

The SortableList component is a powerful tool that enables users to create dynamic lists with drag and drop functionality. It provides smooth animations and customizable options for list items. By following the installation guide and utilizing the available props and events, developers can easily integrate this component into their projects.