drag-and-swap
v0.0.1
Published
Vanilla JS library that allows to swap 2 elements in a page by drag and drop
Downloads
6
Maintainers
Readme
drag-and-swap
Vanilla JS library that allows to swap 2 elements in a page by drag and drop
Usage
Initialize library
var dragAndSwap = new DragAndSwap({
containers: ['#swappercontainer', '#swappercontainer2'], // Array of containers
element: '.swapperbox', // The draggable elements
isEnabled: false, // Enabled on start - default: true
swapBetweenContainers: true, // Swap between different controllers - default: false
onChange: function (boxes) { // Callback when swap is done
console.log(boxes);
}
});
Enable or disable manually
document.getElementById('enable').onclick = () => {
dragAndSwap.enable();
};
document.getElementById('disable').onclick = () => {
dragAndSwap.disable();
};
Build
npm run build
npm run dev
License
Released under the terms of MIT License.