Vanessa 2024-04-02 23:50:22 +08:00
parent 62642c0d0f
commit 655d7cd41b

View file

@ -233,15 +233,8 @@ export class Outline extends Model {
return;
}
const documentSelf = document;
item.style.opacity = "0.38";
const ghostElement = item.cloneNode(true) as HTMLElement;
this.element.append(ghostElement);
ghostElement.setAttribute("id", "dragGhost");
ghostElement.firstElementChild.setAttribute("style", "padding-left:4px");
ghostElement.setAttribute("style", `border-radius: var(--b3-border-radius);background-color: var(--b3-list-hover);position: fixed; top: ${event.clientY}px; left: ${event.clientX}px; z-index:999997;`);
documentSelf.ondragstart = () => false;
let ghostElement: HTMLElement
let selectItem: HTMLElement;
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
if (moveEvent.clientY === event.clientY && moveEvent.clientX === event.clientX) {
@ -249,6 +242,14 @@ export class Outline extends Model {
}
moveEvent.preventDefault();
moveEvent.stopPropagation();
if (!ghostElement) {
item.style.opacity = "0.38";
ghostElement = item.cloneNode(true) as HTMLElement;
this.element.append(ghostElement);
ghostElement.setAttribute("id", "dragGhost");
ghostElement.firstElementChild.setAttribute("style", "padding-left:4px");
ghostElement.setAttribute("style", `border-radius: var(--b3-border-radius);background-color: var(--b3-list-hover);position: fixed; top: ${event.clientY}px; left: ${event.clientX}px; z-index:999997;`);
}
ghostElement.style.top = moveEvent.clientY + "px";
ghostElement.style.left = moveEvent.clientX + "px";
selectItem = hasClosestByClassName(moveEvent.target as HTMLElement, "b3-list-item") as HTMLElement;