DragDoll
DragDoll is a modular and highly extensible drag & drop system written in TypeScript. It's based on Muuri's internal drag and drop system, but redesigned to be used as a general purpose drag & drop system.
- Carefully designed modular API with best possible DX in mind.
- Written in TypeScript with good type inference.
- Small footprint (weighs around 11kB gzipped with all features included).
- MIT licensed.
Install
Node
$ npm install dragdoll eventti tikki
Browser
<script src="https://cdn.jsdelivr.net/npm/eventti@3.0.0/dist/eventti.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tikki@2.0.0/dist/tikki.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dragdoll@0.0.1/dist/dragdoll.umd.js"></script>
Access the library via window.DragDoll
in browser context.
Usage
import { PointerSensor, Draggable, createPointerSensorStartPredicate, autoScroll } from 'dragdoll';
const element = document.querySelector('.draggable');
const pointerSensor = new PointerSensor(element);
const draggable = new Draggable([pointerSensor], {
getElements: () => [element],
startPredicate: createPointerSensorStartPredicate(),
autoScroll: {
instance: autoScroll,
targets: [{ element: window, threshold: 100 }],
},
});
draggable.destroy();
pointerSensor.destroy();
Copyright
Copyright © 2022, Niklas Rämö (inramo@gmail.com). Licensed under the MIT license.