0.0.1 • Published 7 years ago

drag-and-swap v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

drag-and-swap

Vanilla JS library that allows to swap 2 elements in a page by drag and drop

Demo on Plunker

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.