mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-18 04:58:06 +01:00
This commit is contained in:
parent
8c35440a77
commit
74b4a00a2f
42 changed files with 426 additions and 270 deletions
|
|
@ -5,6 +5,7 @@ import {updateHotkeyTip} from "../util/compatibility";
|
|||
import {hasClosestByClassName} from "../util/hasClosest";
|
||||
import {goEnd, goHome} from "../wysiwyg/commonHotkey";
|
||||
import {isMobile} from "../../util/functions";
|
||||
import {App} from "../../index";
|
||||
|
||||
export class Scroll {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -13,7 +14,7 @@ export class Scroll {
|
|||
public lastScrollTop: number;
|
||||
public keepLazyLoad: boolean; // 保持加载内容
|
||||
|
||||
constructor(protyle: IProtyle) {
|
||||
constructor(protyle: IProtyle, app: App) {
|
||||
this.parentElement = document.createElement("div");
|
||||
this.parentElement.classList.add("protyle-scroll");
|
||||
if (!isMobile()) {
|
||||
|
|
@ -41,25 +42,25 @@ export class Scroll {
|
|||
});
|
||||
/// #if BROWSER
|
||||
this.inputElement.addEventListener("change", () => {
|
||||
this.setIndex(protyle);
|
||||
this.setIndex(protyle, app);
|
||||
});
|
||||
this.inputElement.addEventListener("touchend", () => {
|
||||
this.setIndex(protyle);
|
||||
this.setIndex(protyle, app);
|
||||
});
|
||||
/// #endif
|
||||
this.parentElement.addEventListener("click", (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
if (hasClosestByClassName(target, "protyle-scroll__up")) {
|
||||
goHome(protyle);
|
||||
goHome(protyle, app);
|
||||
} else if (hasClosestByClassName(target, "protyle-scroll__down")) {
|
||||
goEnd(protyle);
|
||||
goEnd(protyle, app);
|
||||
} else if (target.classList.contains("b3-slider")) {
|
||||
this.setIndex(protyle);
|
||||
this.setIndex(protyle, app);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private setIndex(protyle: IProtyle) {
|
||||
private setIndex(protyle: IProtyle, app: App) {
|
||||
if (protyle.wysiwyg.element.getAttribute("data-top")) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -70,7 +71,12 @@ export class Scroll {
|
|||
mode: 0,
|
||||
size: window.siyuan.config.editor.dynamicLoadBlocks,
|
||||
}, getResponse => {
|
||||
onGet(getResponse, protyle, [Constants.CB_GET_FOCUSFIRST, Constants.CB_GET_UNCHANGEID]);
|
||||
onGet({
|
||||
data: getResponse,
|
||||
protyle,
|
||||
action: [Constants.CB_GET_FOCUSFIRST, Constants.CB_GET_UNCHANGEID],
|
||||
app
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue