Fix task reordering

This commit is contained in:
JeLuF 2023-02-12 01:02:27 +01:00
parent f2f3ed71d4
commit aa7c031e8a
2 changed files with 5 additions and 5 deletions

View File

@ -528,7 +528,7 @@ function dragOverHandler(ev) {
ev.dataTransfer.dropEffect = "copy"
let img = new Image()
img.src = location.host + '/media/images/favicon-32x32.png'
img.src = '//' + location.host + '/media/images/favicon-32x32.png'
ev.dataTransfer.setDragImage(img, 16, 16)
}

View File

@ -79,7 +79,7 @@ imagePreview.addEventListener('drop', function(ev) {
}
ev.preventDefault()
let moveTarget = ev.target
while (moveTarget && typeof moveTarget === 'object' && moveTarget.parentNode !== imagePreview) {
while (moveTarget && typeof moveTarget === 'object' && moveTarget.parentNode !== imagePreviewContent) {
moveTarget = moveTarget.parentNode
}
if (moveTarget === initialText || moveTarget === previewTools) {
@ -89,17 +89,17 @@ imagePreview.addEventListener('drop', function(ev) {
return
}
if (moveTarget) {
const childs = Array.from(imagePreview.children)
const childs = Array.from(imagePreviewContent.children)
if (moveTarget.nextSibling && childs.indexOf(movedTask) < childs.indexOf(moveTarget)) {
// Move after the target if lower than current position.
moveTarget = moveTarget.nextSibling
}
}
const newNode = imagePreview.insertBefore(movedTask, moveTarget || previewTools.nextSibling)
const newNode = imagePreviewContent.insertBefore(movedTask, moveTarget || previewTools.nextSibling)
if (newNode === movedTask) {
return
}
imagePreview.removeChild(movedTask)
imagePreviewContent.removeChild(movedTask)
const task = htmlTaskMap.get(movedTask)
if (task) {
htmlTaskMap.delete(movedTask)