Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function MultipleContainers() {
const containers = document.querySelectorAll('#MultipleContainers .StackedList');
if (containers.length === 0) {
return false;
}
const sortable = new Sortable(containers, {
draggable: `.${Classes.draggable}`,
mirror: {
constrainDimensions: true,
},
plugins: [Plugins.Releasable],
});
const containerTwoCapacity = 3;
const containerTwoParent = sortable.containers[1].parentNode;
let currentMediumChildren;
let capacityReached;
let lastOverContainer;
// --- Draggable events --- //
sortable.on('drag:start', (evt) => {
currentMediumChildren = sortable.getDraggableElementsForContainer(sortable.containers[1]).length;
capacityReached = currentMediumChildren === containerTwoCapacity;
lastOverContainer = evt.sourceContainer;
containerTwoParent.classList.toggle(Classes.capacity, capacityReached);
});