Skip to content

Commit

Permalink
Simplify sortable destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
agatemosu committed Aug 19, 2024
1 parent 06eb8af commit 242e88e
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const exportContainer = document.querySelector("#export-container");
const exportedImage = document.querySelector("#exported-image");
const blackout = document.querySelector("#blackout");

const draggables = [];
addContainerDrag(imagesBar);

document.querySelector("#new-tier").onclick = () => addRow();
Expand Down Expand Up @@ -161,14 +160,8 @@ function addRowListeners(row, defaultColor) {

deleteButton.onclick = () => {
pickr.destroyAndRemove();
dragInstance.destroy();
row.remove();

const dragIndex = draggables.indexOf(dragInstance);

draggables[dragIndex].destroy();
draggables.splice(dragIndex, 1);

console.log(draggables);
};
upButton.onclick = () => {
moveRow(row, -1);
Expand Down Expand Up @@ -218,10 +211,7 @@ function uploadImages(files) {
}

function addContainerDrag(container) {
const dragInstance = new Sortable(container, { group: "tiers" });
draggables.push(dragInstance);

return dragInstance;
return new Sortable(container, { group: "tiers" });
}

function dynamicStyle(checkbox) {
Expand Down

0 comments on commit 242e88e

Please sign in to comment.