mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
fix: 改进文档树和大纲拖拽排序 (#13999)
fix https://github.com/siyuan-note/siyuan/issues/13901
This commit is contained in:
parent
dc7ccce10a
commit
180338a86f
2 changed files with 14 additions and 9 deletions
|
|
@ -518,14 +518,19 @@ export class Files extends Model {
|
|||
) &&
|
||||
// 防止文档拖拽到笔记本外
|
||||
!(!sourceOnlyRoot && targetType === "navigation-root")) {
|
||||
const nodeRect = liElement.getBoundingClientRect();
|
||||
if (event.clientY > nodeRect.top + 20) {
|
||||
liElement.classList.add("dragover__bottom");
|
||||
event.preventDefault();
|
||||
} else if (event.clientY < nodeRect.bottom - 20) {
|
||||
liElement.classList.add("dragover__top");
|
||||
event.preventDefault();
|
||||
const nodeRect = (liElement as HTMLElement).getBoundingClientRect();
|
||||
if (targetType === "navigation-root" && sourceOnlyRoot) {
|
||||
if (event.clientY > nodeRect.top + nodeRect.height / 2) {
|
||||
(liElement as HTMLElement).classList.add("dragover__bottom");
|
||||
} else {
|
||||
(liElement as HTMLElement).classList.add("dragover__top");
|
||||
}
|
||||
} else if (event.clientY > nodeRect.top + nodeRect.height * 3 / 4) {
|
||||
(liElement as HTMLElement).classList.add("dragover__bottom");
|
||||
} else if (event.clientY < nodeRect.bottom - nodeRect.height * 3 / 4) {
|
||||
(liElement as HTMLElement).classList.add("dragover__top");
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
if (liElement.classList.contains("dragover__top") || liElement.classList.contains("dragover__bottom") ||
|
||||
(targetType === "navigation-root" && sourceOnlyRoot)) {
|
||||
|
|
|
|||
|
|
@ -274,9 +274,9 @@ export class Outline extends Model {
|
|||
return;
|
||||
}
|
||||
const selectRect = selectItem.getBoundingClientRect();
|
||||
if (moveEvent.clientY > selectRect.bottom - 10) {
|
||||
if (moveEvent.clientY > selectRect.top + selectRect.height * 3 / 4) {
|
||||
selectItem.classList.add("dragover__bottom");
|
||||
} else if (moveEvent.clientY < selectRect.top + 10) {
|
||||
} else if (moveEvent.clientY < selectRect.bottom - selectRect.height * 3 / 4) {
|
||||
selectItem.classList.add("dragover__top");
|
||||
} else {
|
||||
selectItem.classList.add("dragover");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue