mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 22:41:58 +03:00
Merge 775426ffe0 into 37cfd2144b
This commit is contained in:
commit
67c0b3d5c7
1 changed files with 13 additions and 4 deletions
13
src/main.ts
13
src/main.ts
|
|
@ -197,14 +197,23 @@ function setupDocInteraction(el: HTMLElement, doc: DocMeta, list: HTMLElement):
|
||||||
window.removeEventListener("mousemove", onMove);
|
window.removeEventListener("mousemove", onMove);
|
||||||
window.removeEventListener("mouseup", onUp);
|
window.removeEventListener("mouseup", onUp);
|
||||||
list.removeEventListener("scroll", onScroll);
|
list.removeEventListener("scroll", onScroll);
|
||||||
cachedItems = null;
|
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
const target = list.querySelector<HTMLElement>(".doc-item.drag-over");
|
let target: HTMLElement | null = null;
|
||||||
|
if (cachedItems) {
|
||||||
|
for (let i = 0, len = cachedItems.length; i < len; i++) {
|
||||||
|
const item = cachedItems[i].el;
|
||||||
|
if (item.classList.contains("drag-over")) target = item;
|
||||||
|
item.classList.remove("drag-over", "dragging");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target = list.querySelector<HTMLElement>(".doc-item.drag-over");
|
||||||
for (const item of list.querySelectorAll(".doc-item"))
|
for (const item of list.querySelectorAll(".doc-item"))
|
||||||
item.classList.remove("drag-over", "dragging");
|
item.classList.remove("drag-over", "dragging");
|
||||||
|
}
|
||||||
document.body.style.cursor = "";
|
document.body.style.cursor = "";
|
||||||
if (target?.dataset.docId) reorderDoc(doc.id, target.dataset.docId);
|
if (target?.dataset.docId) reorderDoc(doc.id, target.dataset.docId);
|
||||||
}
|
}
|
||||||
|
cachedItems = null;
|
||||||
dragging = false;
|
dragging = false;
|
||||||
};
|
};
|
||||||
window.addEventListener("mousemove", onMove);
|
window.addEventListener("mousemove", onMove);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue