mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
This commit is contained in:
parent
c70e3f46ec
commit
9f0eaa6a0b
3 changed files with 9 additions and 6 deletions
|
|
@ -30,6 +30,7 @@ const dragoverScroll: {
|
||||||
space?: number // -1 向上;1 向下
|
space?: number // -1 向上;1 向下
|
||||||
lastTime?: number
|
lastTime?: number
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
export const stopScrollAnimation = () => {
|
export const stopScrollAnimation = () => {
|
||||||
if (dragoverScroll.animationId) {
|
if (dragoverScroll.animationId) {
|
||||||
cancelAnimationFrame(dragoverScroll.animationId);
|
cancelAnimationFrame(dragoverScroll.animationId);
|
||||||
|
|
@ -39,6 +40,7 @@ export const stopScrollAnimation = () => {
|
||||||
dragoverScroll.lastTime = null;
|
dragoverScroll.lastTime = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollAnimation = (timestamp: number) => {
|
const scrollAnimation = (timestamp: number) => {
|
||||||
if (!dragoverScroll.lastTime) {
|
if (!dragoverScroll.lastTime) {
|
||||||
dragoverScroll.lastTime = timestamp - 8;
|
dragoverScroll.lastTime = timestamp - 8;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ import * as path from "path";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {checkFold} from "../../util/noRelyPCFunction";
|
import {checkFold} from "../../util/noRelyPCFunction";
|
||||||
import {clearSelect} from "../util/clear";
|
import {clearSelect} from "../util/clear";
|
||||||
|
import {stopScrollAnimation} from "../../boot/globalEvent/dragover";
|
||||||
|
|
||||||
export class Gutter {
|
export class Gutter {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -183,6 +184,7 @@ export class Gutter {
|
||||||
item.style.opacity = "";
|
item.style.opacity = "";
|
||||||
});
|
});
|
||||||
window.siyuan.dragElement = undefined;
|
window.siyuan.dragElement = undefined;
|
||||||
|
stopScrollAnimation();
|
||||||
});
|
});
|
||||||
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLInputElement }) => {
|
this.element.addEventListener("click", (event: MouseEvent & { target: HTMLInputElement }) => {
|
||||||
const buttonElement = hasClosestByTag(event.target, "BUTTON");
|
const buttonElement = hasClosestByTag(event.target, "BUTTON");
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import {processClonePHElement} from "../render/util";
|
||||||
import {insertGalleryItemAnimation} from "../render/av/gallery/item";
|
import {insertGalleryItemAnimation} from "../render/av/gallery/item";
|
||||||
import {clearSelect} from "./clear";
|
import {clearSelect} from "./clear";
|
||||||
import {dragoverTab} from "../render/av/view";
|
import {dragoverTab} from "../render/av/view";
|
||||||
|
import {dragOverScroll, stopScrollAnimation} from "../../boot/globalEvent/dragover";
|
||||||
|
|
||||||
// position: afterbegin 为拖拽成超级块; "afterend", "beforebegin" 一般拖拽
|
// position: afterbegin 为拖拽成超级块; "afterend", "beforebegin" 一般拖拽
|
||||||
const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element,
|
const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element,
|
||||||
|
|
@ -1174,6 +1175,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
window.siyuan.dragElement.style.opacity = "";
|
window.siyuan.dragElement.style.opacity = "";
|
||||||
window.siyuan.dragElement = undefined;
|
window.siyuan.dragElement = undefined;
|
||||||
}
|
}
|
||||||
|
stopScrollAnimation();
|
||||||
});
|
});
|
||||||
let dragoverElement: Element;
|
let dragoverElement: Element;
|
||||||
let disabledPosition: string;
|
let disabledPosition: string;
|
||||||
|
|
@ -1196,12 +1198,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const contentRect = protyle.contentElement.getBoundingClientRect();
|
const contentRect = protyle.contentElement.getBoundingClientRect();
|
||||||
if (!hasClosestByClassName(event.target, "av__cell") &&
|
if (!hasClosestByClassName(event.target, "av__cell")) {
|
||||||
(event.clientY < contentRect.top + Constants.SIZE_SCROLL_TB || event.clientY > contentRect.bottom - Constants.SIZE_SCROLL_TB)) {
|
dragOverScroll(event, contentRect, protyle.contentElement);
|
||||||
protyle.contentElement.scroll({
|
|
||||||
top: protyle.contentElement.scrollTop + (event.clientY < contentRect.top + Constants.SIZE_SCROLL_TB ? -Constants.SIZE_SCROLL_STEP : Constants.SIZE_SCROLL_STEP),
|
|
||||||
behavior: "smooth"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
let targetElement: HTMLElement | false;
|
let targetElement: HTMLElement | false;
|
||||||
// 设置了的话 drop 就无法监听 shift/control event.dataTransfer.dropEffect = "move";
|
// 设置了的话 drop 就无法监听 shift/control event.dataTransfer.dropEffect = "move";
|
||||||
|
|
@ -1597,6 +1595,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
window.siyuan.dragElement = undefined;
|
window.siyuan.dragElement = undefined;
|
||||||
document.onmousemove = null;
|
document.onmousemove = null;
|
||||||
}
|
}
|
||||||
|
stopScrollAnimation();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue