+ setupListeners() {
+ this.elem.addEventListener('click', event => {
+ const sortItem = event.target.closest('.scroll-box-item:not(.instruction)');
+ if (sortItem) {
+ event.preventDefault();
+ this.sortItemClick(sortItem);
+ }
+ });
+ }
+
+ /**
+ * Called when a sort item is clicked.
+ * @param {Element} sortItem
+ */
+ sortItemClick(sortItem) {
+ const lists = this.elem.querySelectorAll('.scroll-box');
+ const newList = Array.from(lists).filter(list => sortItem.parentElement !== list);
+ if (newList.length > 0) {
+ newList[0].appendChild(sortItem);
+ }
+ this.onChange();
+ }
+