Skip to content

Commit

Permalink
Fix sortable types and separate JS init into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
agatemosu committed Dec 29, 2024
1 parent ab7e860 commit 099d3db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,26 @@ function dynamicStyle(e) {

// #region Setup

function main() {
function setUpSortable() {
/** @type {HTMLElement} */
const imagesBar = document.querySelector("#images-bar");
Sortable.create(imagesBar, { group: TierRow.sortableGroup });
}

function setUpEvents() {
const newTierButton = document.querySelector("#new-tier");
const selectImagesButton = document.querySelector("#select-images");
const imagesBar = document.querySelector("#images-bar");
const checkboxes = document.querySelectorAll(".dynamic-style");

newTierButton.addEventListener("click", addNewTier);
selectImagesButton.addEventListener("click", selectImages);

Sortable.create(imagesBar, { group: TierRow.sortableGroup });

for (const checkbox of checkboxes) {
checkbox.addEventListener("change", dynamicStyle);
}
}

main();
setUpSortable();
setUpEvents();

// #endregion
2 changes: 1 addition & 1 deletion src/tier-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class TierRow extends HTMLElement {
this.createColorPicker();

// Sortable
const tierSort = this.querySelector(".sort");
const tierSort = /** @type {HTMLElement} */ (this.querySelector(".sort"));
this.sort = new Sortable(tierSort, { group: TierRow.sortableGroup });

// Options
Expand Down

0 comments on commit 099d3db

Please sign in to comment.